js error not trapped by some browser ?

lcollong

FabriKant d'applications web
Hi,

I'm using ajaxified list with ajax links. The "real" list has several joins. In order to minimize the loading time of the list as well as using some specific features (order of element...), I have a second list without joins. I use custom links so the edit link bring up the right full joined form.

Everything is fine. However, on closing the popup window, Fabrik.js Fabrik.openSingleView function is producing an error on this line (around #455) :
Code:
                    Fabrik.blocks[k].destroyElements();
the reason is the way "k" is build :
Code:
var k = view + '_' + list.options.formid + '_' + rowId;
formid is the form connected to the displayed list. But since I use custom link, the real formid is given by the url used to open the window. Not the list's formid in this case.

This part of the code is inside a "try". So in most browser, the result is only showing the "catch" which displays the error message. And it seems to not have some side effect (actually not destroyed, event not triggered).

But in some browser (some specific version of Firefox for linux ?...), these lines produces a fatal error not trapped. So the rest of the js on the page is broken.

I did the following patch on the file media/com_fabrik/js/fabrik.js in order to "catch" the right formid from the url. But I'm not sure to understand why the "isCustom" is not set in this case and how the whole thing is intended to work actually.

However, I do not trigger any error this way :

Code:
        // if it's a custom link, don't add our junk 'n' stuff
        if (jQuery(target).data('iscustom') !== 1) {
            url += url.contains('?') ? '&tmpl=component&ajax=1' : '?tmpl=component&ajax=1';
            url += '&format=partial';
        }

        // APCHEA
        var apchea_form_id = list.options.formid;
        if (jQuery(target).data('iscustom') !== 1) {
            var bouts = url.split('/');
            for (var i = 0; i<bouts.length; i++) {
                if (bouts[i] == 'form') apchea_form_id = bouts[i+1];
            }
        }
        //console.log(apchea_form_id);
        // APCHEA
        title = a.prop('title');
        loadMethod = a.data('loadmethod');
        if (loadMethod === undefined) {
            loadMethod = 'xhr';
        }

        // Only one edit window open at the same time.
        jQuery.each(Fabrik.Windows, function (key, win) {
            win.close();
        });

        winOpts = {
            modalId   : 'ajax_links',
            id        : listRef + '.' + rowId,
            title     : title,
            loadMethod: loadMethod,
            contentURL: url,
            onClose   : function () {
//APCHEA        var k = view + '_' + list.options.formid + '_' + rowId;
                var k = view + '_' + apchea_form_id + '_' + rowId;
                try {
                    Fabrik.blocks[k].destroyElements();
                    Fabrik.blocks[k].formElements = null;
                    Fabrik.blocks[k] = null;
                    delete (Fabrik.blocks[k]);
                    var evnt = (view === 'details') ? 'fabrik.list.row.view.close' : 'fabrik.list.row.edit.close';
                    Fabrik.fireEvent(evnt, [listRef, rowId, k]);
                } catch (e) {
                    console.log(e);
                }
            }
        };

Does it make sense ?
 
Looks OK.

The iscustom stuff is intended for links which aren't links to Fabrik pages, so we don't add our very specific stuff like format=partial, which would kill anything that doesn't have that view type.

But really, I don't think I ever got round to properly finishing off allowing custom links in popups, simply because popups are soooo Fabrik specific.

I'll have a think, see if I can figure out a way to accomodate linking to copies of the same list.

-- hugh
 
I'm trying to setup things as much close as the way Fabrik works. The power of multiple list on the same table is great. With normal load (no ajax) everything works well. Using ajax brings comfort and modernism to the user but still having situation where I'm not sure to fully understand the way it works.

My setup of the display list (details-->links-->custom edit url) is : index.php?option=com_fabrik&view=form&formid=14&rowid={rowid}
My setup of the element in this list use as edit/detail link is just "link to details" swjtched "yes". No custom link at the element level, target=default.

The result on the rendered list#65 page is :

for the edit button at the end of line :
HTML:
<a data-loadmethod="xhr" class="fabrik_edit fabrik__rowlink btn-default" data-list="list_65_com_fabrik_65" data-isajax="1" data-rowid="717" data-iscustom="1" href="/fr/administration-des-ventes/factures-liste/form/14/717" title="Modifier">
    <i data-isicon="true" class="icon-edit "></i> Modifier</a>

for the row element marked as "link to detail" :
HTML:
<a data-loadmethod="xhr" class="fabrik___rowlink  fabrik_edit" data-list="list_65_com_fabrik_65" data-isajax="1" data-rowid="717" data-iscustom="0" href="/fr/administration-des-ventes/factures-liste/form/14/717">
BR-0717</a>

the "iscustom" is not set in the second case.

Also, using the regular edit link open a window with the right form and rowid but which includes the whole site.
I've tried adding "&listid=14" in the url without changing anything.

Finally, changing the custom link to : index.php?option=com_fabrik&view=form&formid=14&rowid={rowid}&format=partial&tmpl=component does the trick (but it triggers the error trap on "destroyElements" on closing the window as explained on my first post). Still no need to edit the element used as link to detail. But now both acts the same.

It seems that the element links is built with a default value which does not use the list setup, but behave better than the basic list's custom link. The setup of the list#14 is "ajaxfiied links : no" ajaxified navigation : no. I've tried with yes/yes with out any change....

For now, I found the way to have everything working. So far so good. But I think the iscustom should be set to 1 in the element link also. And the formid should come from url when "option=com_fabrik" ans "iscustom = 1" in fabrik.js "onClose".
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top