
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
sitefinitysteve
asked on 22 May 2012, 02:58 PM
I need a checkbox bound to a bool in my model...however on click I need to persist that change to a webservice.
So in this case I need the checkbox to show the state of the model, then the click event I need to send the value and then call a function to update a count based on the model.
What's HAPPENING though it seems is this
1) Checked
2) Ajax Call
3) Ajax Complete
4) Function Runs to get count (checks bool state)
5) Bool state changed
So I know this because if I set a timeout on step 4
...then the count updates okay...
So if I could subscribe to a change on the property (somehow) then the function could run AFTER it changes.
Steve
data-bind=
"checked: AvailableToHamilton, click: shareWith"
So in this case I need the checkbox to show the state of the model, then the click event I need to send the value and then call a function to update a count based on the model.
What's HAPPENING though it seems is this
1) Checked
2) Ajax Call
3) Ajax Complete
4) Function Runs to get count (checks bool state)
5) Bool state changed
So I know this because if I set a timeout on step 4
success:
function
(e) {
setTimeout(
function
(){
viewModel.getTotalCapacity();
}, 100);
}
...then the count updates okay...
So if I could subscribe to a change on the property (somehow) then the function could run AFTER it changes.
Steve
5 Answers, 1 is accepted
0
Hi,
Atanas Korchev
the Telerik team
The click event of the checkbox is raised before its value is updated. You can try using the change event instead.
Regards,Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 23 May 2012, 01:26 PM
OH! I didn't even know that was an event to hook into...I don't see it anywhere in the documentation\demos
I will try it, thanks
I will try it, thanks
0

sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 23 May 2012, 01:37 PM
...seems to work!
Thanks again
Thanks again
0
Accepted
Hi,
Atanas Korchev
the Telerik team
By "change" event I meant the DOM "change" event of the checkbox. You should use the events binding to handle it.
Greetings,Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 23 May 2012, 01:40 PM
Ahh is that what it is, okay thanks (I noticed data-bind="change: " didn't work so I tried that next.