• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Javascript errors including Uncaught ReferenceError: Fabrik is not defined

digger149

New Member
I have joomla 3.2 with fabrik rc2 + github as of today.
Its a development site, the form is here: fm-info.co.uk/index.php/card-data
Its using the standard protostar template to avoid potential issues.

I have created 2.js and 3.js based on forum posts to act on the forms.
The problems are:

1 - The main form chrome diags show Uncaught ReferenceError: Fabrik is not defined when 3.js runs, it contains:
Code:
Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
var gox = form_3.formElements.get('card_data___firstname').getValue();
alert('start');
form.result = false;
});

2. The "find surgery" links pops up a new form, but gives this error: Uncaught TypeError: Cannot call method 'get' of undefined
2.js contains:
Code:
Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
var go = form_2.formElements.get('popup___surgeryname').getValue();
alert('alert');
form.result = false;
 
})

This seems odd, in that the Fabrik.addEvent error does not recur on the popup

I would be greatful if anyone could point me in the right direction
 
Javascript is loaded asynchronously - so you need to do something like:
JavaScript:
requirejs(['fab/fabrik'], function () {
    Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
        var gox = form_3.formElements.get('card_data___firstname').getValue();
        alert('start');
        form.result = false;
    });
});
This ensures that fabrik.js (which defines the global Fabrik) is run before your own javascript.
 
Thanks very much for that, it worked for the "Fabrik not defined" error.

Regarding the second error, I had to work it out. There wasn't a clear example in the forum or wiki, so in case anyone else has the problem here it is:

Code:
requirejs(['fab/fabrik'], function () {
    Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
        var form_2 = Fabrik.blocks['form_2'];
        var sname = form_2.formElements.get('popup___surgeryname').get('value');
        var sadd = form_2.formElements.get('popup___surgeryaddress').get('value');
        var sphone = form_2.formElements.get('popup___surgeryphone').get('value');
        var form_3 = Fabrik.blocks['form_3'];
        form_3.formElements.get('card_data___surgeryname').update(sname);
        form_3.formElements.get('card_data___surgeryaddress').update(sadd);
        form_3.formElements.get('card_data___surgeryphone').update(sphone);
        form.result = false;
    });
});

It passes the data from one pop-up form to the calling form.

All I need now is to work out how to close the popup on submit, can anyone offer any help?

Cheers
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top