Monday, September 30, 2013

jQuery script not available in AJAX loaded page

jQuery script not available in AJAX loaded page

I have an anonymous jQuery function that looks like this:
( function( $ ) {
"use strict";
var CHEF = window.CHEF || {};
CHEF.fancyTitler = function() {
if( $( '.k-fancy-title' ).length ) {
$( '.k-fancy-title' ).wrap( '<div class="k-fancy-title-wrap"
/>' );
}
}
// + a bunch of other functions inside
$( document ).ready( function() {
CHEF.fancyTitler();
// + a bunch of other function inits
} );
} )(jQuery);
...then I load some content on to the page by using AJAX. Everything is
fine regarding content loading, however .k-fancy-title element doesn't get
wrapped. It's kinda obvious that I need to reload/re-call/whatever my
anonymous function in order to wrap ajax loaded content with DIV
(.k-fancy-title-wrap).
How do I do that?

No comments:

Post a Comment