Execute javascript function on AJAX calls to a specific page

0

I have a site in Laravel where the content is loaded dynamically with AJAX, that is, in each call Laravel returns only the view of the part that I need, on a certain page I need to initialize a jQuery plugin that I only use on this page . If I initialize this plugin on all calls will work, but I'll end up creating an unnecessary overhead. What is the best method of passing this JS function call when I call that page to happen?

    
asked by anonymous 12.11.2014 / 01:38

1 answer

1

Using or implementing some lazy load library, which loads scripts on demand.

How about something like:

myLib.load(['jquery', 'jquery-ui', 'fancybox'], function(){
    // Isso aqui só vai rodar quando as 3 dependências forem carregadas
});
    
12.11.2014 / 02:02