Fabrik 3 Javascript Plugin

fariebk

New Member
Hi, I was looking in the Fabrik 3 SVN and didn't see the javascript plugin, am I skipping over that or has that not be transferred over yet?

Thanks!
 
yes its not yet been moved over because it is replaced with a system where the list fires events at the window, for example:

Code:
 window.fireEvent('fabrik.list.order', [this, orderby, orderdir]);

that means that any js code attached in the following way

Code:
window.addEvent('fabrik.list.order', function(list, orderby, orderdir){
   ..... add your code here
});

will be run.
If you want it to run for a specific list you could do :

Code:
window.addEvent('fabrik.list.order', function(list, orderby, orderdir){
   if(list.id == 1){
     ..... add your code here for list 1
   }
});

and if you wanted to stop the ordering from occuring for list1 you can do


Code:
 window.addEvent('fabrik.list.order', function(list, orderby, orderdir){
    if(list.id == 1){
     ..... add your code here for list 1
     list.result = false; // stops the ordering
   }
 });
 
Hi sorry can you elaborate a bit more, I want to close a modal window after submit with fabrik 3, I saw on an other post for 2.x that you suggested to use the fabrikjs plugin, but I'm using fabrik 3 and dont see the js plugin for it and to be honest I didn't understand what you said above.
Thanks!
 
Create a X.js file in components/com_fabrik/js/ (replace the X with your from's id)
then add this:

Code:
Fabrik.addEvent('fabrik.form.submit.end', function (form) {
 // form is a reference to the main js object that controls the form.
 //put your js code here to close the popup window
});
 
Hi Rob, thanks for the answer it was able to solve the problem, now I have an otherone, the window is been close even if the validation was not ok, is there a way to know if the validation was ok or need attention so I can trigger the window close.

Thanks again for your answers and help, really apreciate them!
 
The fabrik.form.submit.end is called regardless of success or failure, at the very end of submit processing.

If you need to distinguish between a successful and a failed submit, instead of using that one, you can use the two distinct events, fabrik.form.submitted and fabrik.form.submit.failed, which ... well, should be obvious.

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

Thank you.

Members online

Back
Top