Javascript files (form_#.js or details_#.js) not loaded on subsequent views

Bauer

Well-Known Member
I have a list that is 'ajaxified' so that opening the edit or details view is in a modal popup.

Both the form view and details view have their own javsacript files. (e.g. form_24.js and details_24.js) The popup works and the javascript files are loaded and work correctly if either the Edit or Details button is clicked.

But if, after I close the modal popup, I click either the Edit or Details (in any row) again - e..g to edit/view details in another row - the javascript files are not loaded with the modal popup. (This only happens if both the Edit and Details buttons had been previously clicked.)
 
Ah, no, I see the problem.

Hmmm. We use requirejs to include those, which of course means they won't get included the second+ time.

I'll have to have a think about this one.

-- hugh
 
Not a lot I can do about this right now.

However ... it should be possible to do most stuff you need to do on a form load by hanging it on Fabrik events. So code like ...

Code:
requirejs(['fab/fabrik'], function() {
    Fabrik.addEvent('fabrik.form.elements.added', function(form) {
        alert('Elements added');
    });

    Fabrik.addEvent('fabrik.form.loaded', function(form) {
        alert('Form loaded');
    });
    alert("I done bin loaded");
});

... will run the two Fabrik event code functions on all loads. The "I bin loaded" will only run the first time.

So anything you need to do on a form load, just wrap in the fabrik.form.loaded function.

There's an equivalent fabrik.list.loaded as well.

-- hugh
 
Well at least it's not a "just me" thing this time.:D
I thought there would be a way to do that - and have used as similar solution before, I know. But I can never remember where to find a list of those event triggers - and even in the Wiki I'm sure the list is incomplete.

There's a LOT to know about the inner workings of Fabrik. I could never catch up to people like you, Rob, and troester. :oops: (What happened to the 'embarrassed' emotion?)

BTW. Since I posted that, I 'solved' the issue by setting Details access to 'Nobody' (it's not really needed since the list is already filtered to the user who 'owns' the record.).

But I suppose it's something that should be kept 'on the radar', as you say - or an internal solution found - because it affects any lists where other Fabrik users are doing the same thing.

When I get the time, I'll experiment with this solution nonetheless - and let you know how it goes.
 
I always figure out the events by just looking at the relevant JS file, like media/com_fabrik/form.js and search for "fabrik.form.". :)

One Of These Days I'll update the wiki.

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

Thank you.

Members online

Back
Top