[jQuery] livequery always fires initial toggle function following ajax response
I'm trying to use livequery, toggle, and ajax together. The toggle methods
fire off ajax requests that will update the div containing the DOM elements
that are bound to the click/toggle (the reason I'm trying to use livequery
in the first place). Unfortunately, it seems like livequery always rebinds
to the initial toggle fn first, so I lose the benefit of using toggle. If
I remove the ajax calls, the toggle works correctly of course.
Any suggestions appreciated.
code snippet:
function toggleExample() {
$(".toggle_me").livequery(function() {
$(this).toggle(
function() {
alert($(this).attr("id") + " binding to first toggle fn");
$.get(/* ajax params here, the updated div includes the DOM elements
marked with class="toggle_me" */);
},
function() {
alert($(this).attr("id") + " binding to second toggle fn");
$.get(/* ajax params here, the updated div includes the DOM elements
marked with class="toggle_me" */);
});
});
}
--
View this message in context: http://www.nabble.com/livequery-always-fires-initial-toggle-function-following-ajax-response-tp21223597s27240p21223597.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.