[jQuery] reaplying rules to returned data
Hi, there!
Is there more effective and beautiful way to reload all rules than that? Or a plugin, or something ab<span style="font-weight: bold;">out that</span>
<br clear="all"><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<span style="font-weight: bold;">$(document).ready(function(){</span><br style="font-weight: bold;"><span style="font-weight: bold;"> $('.content').load('site.php?page=start');</span><br style="font-weight: bold;"><span style="font-weight: bold;">
$(function() {</span><br style="font-weight: bold;"><span style="font-weight: bold;"> var addClickHandlers = function() { </span><br style="font-weight: bold;"><span style="font-weight: bold;"> $(".menu li").click(function() {
</span><br style="font-weight: bold;"><span style="font-weight: bold;"> $(".content").load('site.php',{page: $(this).attr('name')}, function(){</span></blockquote><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<span style="font-weight: bold;"> $(this).show("slow"); </span></blockquote><div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<span style="font-weight: bold;">//below goes discontent</span></blockquote></div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><span style="font-weight: bold;">
$(".menu li").unbind('click');</span><br style="font-weight: bold;"><span style="font-weight: bold;"> addClickHandlers();</span><br style="font-weight: bold;"><span style="font-weight: bold;">
}); </span><br style="font-weight: bold;"><span style="font-weight: bold;"> });</span></blockquote><div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex; font-weight: bold;" class="gmail_quote">
//#loadeddata is returned by request clicking .menu li (just looking if rules are reaplied)
</blockquote></div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<span style="font-weight: bold;"> $("#loadeddata").click(function() {$(this).color('red');});</span><span style="font-weight: bold;"> </span><br style="font-weight: bold;"><span style="font-weight: bold;">
};</span><br style="font-weight: bold;"><span style="font-weight: bold;"> addClickHandlers();</span><br style="font-weight: bold;"><span style="font-weight: bold;"> });</span><br style="font-weight: bold;">
<span style="font-weight: bold;">});</span>
</blockquote>
I don't like this because I have to use callbacks all the time and to unbind events that are doubling, trippling and so on while returning new data and reaplying events
<br style="font-weight: bold;"><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><span style="font-weight: bold;"> $(".menu li").unbind('click');
</span><br style="font-weight: bold;"><span style="font-weight: bold;"> addClickHandlers();</span>
</blockquote>
--
____________________________
С уважением, Марат Мамяшев
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/