KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a problem with Knockout.js. I want to pass username to a function and display it on alert. Something strange is happening. I get alerts each time when i refresh page with correct usernames, but after i click it i don't get any response. What is wrong here? Here is my code: <ul data-bind="foreach: contacts"> <li class="user-box"><span class="user-box-name" data-bind="text: username, click: $root.userClick(username)"></span> </li> </ul> and self.userClick = function (x) { alert(x); }
Tags (comma-separated)
Save Edits
Cancel