Ajaxify and custom javascript

Status
Not open for further replies.
Hi,

I have custom javascript for a list (list_X.js). When this list is being called in a module with Ajaxify on, the custom javascript is no longer working properly. It only works in the first page. Doesn't work in second page onwards and when I come back to the first page from other pages.

Ajaxify is not a must for me. So alternatively, if I can get pagination work in modules without Ajaxify, it can be a solution for me. Any way to make pagination work in modules without Ajaxify?
 
Ok. I kind of understand what is wrong with my custom js. It is only called at the page load so it does not work when it comes to manipulating DOMs created by Ajax. Is there any way to do Ajax callback?
 
You should be able to use a Fabrik event. After we've finished processing the AJAX response from a pagination (or anything else which reload the list via AJAX), we call

Code:
Fabrik.fireEvent('fabrik.list.submit.ajax.complete', [this, json]);

... so if you do ...

Code:
Fabrik.addEvent('fabrik.list.submit.ajax.complete', function(list, data) {
   // your code here
});

... in your list_X.js, it should be fired. Note that although the firEvent refers to 'json', by the time that event fires, the json has been decoded into an object.

Also note that this is fired after we have updated the DOM. If you need to tweak the data before we display it, I could add a fabrik.list.submit.ajax.start, which would allow you to tweak that data object before we render it.

And another note ... you probably have to retain your existing page load event, as this event will only fire after an AJAX load. So you probably want to extract your main logic into a function, which you call from two places - the load event, and the AJAX event.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top