vojtech-dobes / nette.ajax.js

Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
https://componette.org/vojtech-dobes/nette.ajax.js/
MIT License
149 stars 85 forks source link

best practice for live initiation #105

Open Ciki opened 10 years ago

Ciki commented 10 years ago

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?

vojtech-dobes commented 10 years ago

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

Ciki commented 10 years ago

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?

vojtech-dobes commented 10 years ago

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.

Ciki commented 10 years ago

OK, thanks