nette.ajax.js icon indicating copy to clipboard operation
nette.ajax.js copied to clipboard

best practice for live initiation

Open Ciki opened this issue 11 years ago • 4 comments

what is the best practice to automatically init all a.ajax links even those dynamically loaded?

should I write custom init function, sth like

$.nette.ext('init', {
    load: function (rh) {
        $('body').off('click.nette', this.linkSelector, rh).on('click.nette', this.linkSelector, rh);
// ...
}
}

or manually call $.nette.load() or sth else?

Ciki avatar Sep 27 '14 14:09 Ciki

Well, a.ajax is absolutely default behavior of the library. Just call $.nette.init() and that should be it. It should work.

vojtech-dobes avatar Sep 27 '14 16:09 vojtech-dobes

but what about when I create new links e.g. using jquery & inject them to DOM. SHould they be automatically ajaxified or is this my responsibility?

Ciki avatar Sep 27 '14 19:09 Ciki

I see... then calling $.nette.load() is now the right way :). But I see the disadvantage... there should be more streamlined way to make elements ajaxified. I will try to prepare solution soon.

vojtech-dobes avatar Sep 27 '14 21:09 vojtech-dobes

OK, thanks

Ciki avatar Sep 28 '14 08:09 Ciki