[SOLVED] Javascript Form_X.js -- Fabrik is not defined

Status
Not open for further replies.

Basdub

Member
I have added a script to my form using the form_X.js approach.
Here's the script in it:
HTML:
(function($){ 
   
    $('button[name="Submit"]').each(function(e){
        $(this).css('display','none');
        Fabrik.addEvent('fabrik.form.page.change', function(form){
            var s = form.currentpage;
            var f = 1;
        });
       
    });
})(window.jQuery);

When it gets to adding the event, I get Fabrik is not defined.

There's another post here about it but the solution has never been posted and I can't reply to that forum.

http://fabrikar.com/forums/index.php?threads/uncaught-referenceerror-fabrik-is-not-defined.34367/

Could someone post the workaround or solution please

Thanks
 
Couldn't find the answer yesterday and this morning took me 5 mins after my post.

Here's the solution:

I have wrapped my function $('button.... inside a requirejs function like so:

HTML:
(function($){       
    requirejs(['fab/fabrik'], function () {
        $('button[name="Submit"]').each(function(e){
            $(this).css('display','none');
            Fabrik.addEvent('fabrik.form.page.change.end', function(form){
                var s = form.currentpage;
                var f = 1;
            });
 
        });
    });
       
})(window.jQuery);

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

Thank you.

Members online

Back
Top