|
|
|
|
|
by sbank
3953 days ago
|
|
Thank you for this comment. Several things there that I will look into! If you don't mind, could you elaborate a bit on the following: > - $(document).on('event', '.element', ..) is fantastic. Never debug events ever again > - a single javascript function that accepts a DOM element (body, a modal, section) and initializes all the elements the app knows of (selectize elements, date/time pickers, etc) inside that container |
|
Simple example:
So if you load in content via AJAX (I do this a lot for table views of data and the user wants to see a single record), rather than go to a separate page, I do an ajax call, put the result into a Twitter bootstrap modal, show the modal, and when the bs.modal.shown event fires, that "single javascript function" with the modal as the parameter is called, and it initializes all the javascript needed for that particular DOM container.Example:
The general_init function will initialize all my selectize elements (among other things) as such: So when writing forms, lets say to create a new "Event Ticket" I simply plop in a text field with a class of "guest-select" and I instantly have an AJAX powered search field to find/create a guest to assign that ticket to.