Tips and tricks
So recently I had to make ajax requests that pull in a piece of page with some scripting inside. The context does not matter much, what matters is the script executed fine on my localhost but not as a WordPress installation in a WP blog. After some head banging turns out that in my localhost I was using jQuery 1.9.1 and WP uses 1.8.3 .
So jQuery 1.9.1 seems to find the script tags too in the pulled ajax content. But what interests me is the WP plugin functionality. I could deregister the 1.8.3 and register the 1.9.1 but that is a very very bad practice. So I prefer a dirty approach better then a bad practice that could damage others.
I wrap my script in a invisible div like so
Then in the javascript just do
jQuery('.toexecute').each(function(){ var _t = jQuery(this); if(_t.hasClass('executed')==false){ eval(_t.text()); _t.addClass('executed'); } })
at the end of the document and at the end of each complete ajax request.