I have tried very hard to get my own JS code running when the next button is clicked but so far I have failed.
Based on this page:
http://fabrikar.com/forums/index.php?wiki/form-javascript/
I have created a file called form_X.js with the following code:
I get no JavaScript errors and fabrik.form.elements.added gets triggered when the page loads and fabrik.form.submit.start gets triggered when the form is submitted but none of them get triggered when the next page is triggered.
What I need is an event that gets triggered if the Next button is clicked and all the validations pass (ie, if the next page is actually shown). According to this page, it looks possible in Fabrik v2 with the event onCompleteElementValidation but I think it has got gone missing in v3 when converted to the new system:
http://fabrikar.com/wiki/index.php/Form_plguin_javascript
I sort of expected fabrik.form.submitted to do this as it is called when the form is submitted with AJAX (which is effectively what happens on each page). However it is only partially submitted for validation so maybe there needs to be a new event something like fabrik.form.submit.validate [form, json] which is called after a (successful?) validation occurs so would be called per page (or per element if AJAX validation was set to yes). As long as it was possible to tell which page (or element) was validated successfully (or otherwise) this would be perfect for me and I think very flexible or other needs.
Let me know if I'm missing something or if this could be easily implemented. Whether this is possible or not is a fundamental point on how we design this system.
Thanks for considering!
Based on this page:
http://fabrikar.com/forums/index.php?wiki/form-javascript/
I have created a file called form_X.js with the following code:
Code:
Fabrik.addEvent('fabrik.form.doelementfx', function(form){
alert('Event - fabrik.form.doelementfx');
});
Fabrik.addEvent('fabrik.form.elements.added', function(elements){
alert('Event - fabrik.form.elements.added');
});
Fabrik.addEvent('fabrik.form.groups.save', function(form){
alert('Event - fabrik.form.groups.save');
});
Fabrik.addEvent('fabrik.form.groups.save.start', function(form){
alert('Event - fabrik.form.groups.save.start');
});
Fabrik.addEvent('fabrik.form.groups.save.end', function(form, json){
alert('Event - fabrik.form.groups.save.end');
});
Fabrik.addEvent('fabrik.form.group.delete', function(form, event){
alert('Event - fabrik.form.group.delete');
});
Fabrik.addEvent('fabrik.form.group.delete.end', function(form, event, groupId, repeatCounter){
alert('Event - fabrik.form.group.delete.end');
});
Fabrik.addEvent('fabrik.form.group.duplicate', function(form, event){
alert('Event - fabrik.form.group.duplicate');
});
Fabrik.addEvent('fabrik.form.group.duplicate.end', function(form, event, groupId, repeatCounter){
alert('Event - fabrik.form.group.duplicate.end');
});
Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button){
alert('Event (with form submission prevention) - fabrik.form.submit.start');
form.result = false;
});
Fabrik.addEvent('fabrik.form.submitted', function(form){
alert('Event - fabrik.form.submitted');
});
Fabrik.addEvent('fabrik.form.update', function(form, json){
alert('Event - fabrik.form.update');
});
Fabrik.addEvent('fabrik.form.reset', function(form){
alert('Event - fabrik.form.reset');
});
I get no JavaScript errors and fabrik.form.elements.added gets triggered when the page loads and fabrik.form.submit.start gets triggered when the form is submitted but none of them get triggered when the next page is triggered.
What I need is an event that gets triggered if the Next button is clicked and all the validations pass (ie, if the next page is actually shown). According to this page, it looks possible in Fabrik v2 with the event onCompleteElementValidation but I think it has got gone missing in v3 when converted to the new system:
http://fabrikar.com/wiki/index.php/Form_plguin_javascript
I sort of expected fabrik.form.submitted to do this as it is called when the form is submitted with AJAX (which is effectively what happens on each page). However it is only partially submitted for validation so maybe there needs to be a new event something like fabrik.form.submit.validate [form, json] which is called after a (successful?) validation occurs so would be called per page (or per element if AJAX validation was set to yes). As long as it was possible to tell which page (or element) was validated successfully (or otherwise) this would be perfect for me and I think very flexible or other needs.
Let me know if I'm missing something or if this could be easily implemented. Whether this is possible or not is a fundamental point on how we design this system.
Thanks for considering!