Javascript seems to be disabled in all jQuery UI tabs that are loaded through ajax. I am testing this with jQuery tooltips and .click() alerts. Javascript works fine in tabs that aren't loaded through ajax (IDs present on the page).
Here is how I am calling the tabs:
$(function() {
$('#foo-tabs').tabs(
{
heightStyle: 'content',
// Callback run when selecting a tab
beforeLoad: function(event, ui) {
// If the panel is already populated do nothing
if (ui.panel.children().size() > 0)
return false;
//load specific ID within target page
ui.panel.load($('a', ui.tab).attr('href') + $('a', ui.tab).attr('data-target'));
// stop the default process (default ajax call should not be launched)
return false;
}
}
);
});
Here's the javascript I'm trying to activate:
$(function() {
$( '.activate-tooltip' ).tooltip();
});
And a test:
$(function() {
$("h1").click(function() {
alert("zomg javascript works!");
});
});
Any ideas on how to get javascript working in all ajax loaded tabs? Thank you for taking the time to go through this!
livefunction of jquery to trigger click event for dynamically created html.$("h1").live("click", function(){ alert("zomg javascript works!"); });.live()function has been deprecated since jQuery 1.7 was released; they should use.on()(1.7+) or.delegate()in preference to.live(). The only time you should be writing new code using.live()is if you're using a version of jQuery prior to 1.4.3 (when.delegate()was added); and if that's the case you should probably upgrade.$(document).on('click', 'h1', function(){});..oninstead of.live