Questions on list JavaScript

PaulV888

Member
Hi,

I was playing with list JavaScript based on this Wiki the other day and noticed

1) That the added event is fired for all your list on the current page. E.g. I have fabrik_list_1 and fabrik_list_2 on the page and create a list_1.js with a
Fabrik.addEvent('fabrik.list.loaded',function(list) then this get called for list 1 as well as for list 2.

An easy workaroud is to hardcode the expected id in your list_1.js and check this against list.id However is this a bug or a feature? I.e. should we add something to the Wiki or update the code?

2) The updaterows event comes without any context, which seems to make sense looking at line 1324 in list.js
Code:
                Fabrik.fireEvent('fabrik.list.updaterows');
There is no ", [this, data]" like the update event on the next line. Basically same question on this.

Regards,
Paul
 
It's a feature. If you have more than one list (or form, or viz, whatever you are listening for Fabrik events on), then you need to test the id ...

Code:
Fabrik.addEvent('fabrik.list.loaded',function(list) {
   if (list.id === 'list_12_com_fabrik_12') {
      // blah blah
   }
});

I'm pretty sure updaterows is deprecated, we were using that to do something specific with the inlineedit plugin (which is deprecated), so just use fabrik.list.update instead, which gets the context.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top