I have some jquery code to fire on input-change:
$("[data-binding] input").bind('change', function () {
debug('changing');
PerformWCFCall($(this));
});
the debug
-function is simply a call to console.log
The problem is that it randomly doesn't fire. 90% of the time everything works fine, but then all of a sudden it stops working a couple of times, and starts working again.
the PerformWCFCall
doesn't contain any binding-code, but only a async call to a WCF service.
I'm also calling $("[data-binding] input").unbind('change')
before the call to .bind
just in case. But I'm having a hard time figuring this one out.
Hope someone can help
Let me know if you need any more information!
What does 'PerformWCFCall' do with the input? Does it replace it? - If so, try using 'live' instead of bind....or rebind after the call to 'PerformWCFCall'.
Your jquery selector looks suspicious, are you trying to bind on input elements that has a property called data-binding? If so you should use this selector instead:
$('input[data-binding]')
I see someone already suggested the live event, so i'm wondering when you do the binding - is it after document.ready?
Also if you're using FireFox - install FireBug if you haven't already (or use IE developer tools for IE, or the debugger in chrome) to see if the handler stops working (the 10% of the time) after a javascript error - it could be part of the WCF call gone wrong. Also install fiddler (http://www.fiddler2.com/fiddler2/) to inspect the traffic from your client to your WCF service. Something gone wrong here can halt the exection of your javascript.
确保PerformWCFCall
修改通过$("[data-binding] input")
选择的节点,如果这样做的话会使用live()
代替bind()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.