Cancel/Close button on form

Hi guys,

We have a bit of a dilemma. We have a list that has a form on it. On that form is another list with child records that has a view form. The problem is with the "cancel" button which is really a back button. So if I open the parent list and then the parent form and then the child form. If I go back to the parent form and hit the "Close" button it goes back to the child form:

Parent List
-> Parent Form
-> Child Form

At this point the back button on the Parent form goes to the Child form, not the Parent List. This is normal back button behavior, so nothing wrong, but we need the close/cancel on the Parent form to ALWAYS go back to the Parent list.

Any tips on the best way to accomplish this?

Best regards,
 
Hi,

This ALSO applies to the SAVE button. It will also attempt to go back to the child form after saving the parent form if the child form has been opened.

Best regards,
 
I use this way in form_XX.js file:
JavaScript:
jQuery("#form_XX button[name = 'Goback']").attr('onclick', '');
jQuery("#form_XX button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=XX";
    jQuery(location).attr('href',url);
});
And for Save button use form redirect plugin and redirect to your list.
 
Hi,

Thank you so much! Where does the form_xx.js file go and is this this ONLY code that needs to go into it. I have a rather bad relationship with javascript;)

Best regards,
 
Hi,


The plugin worked perfectly, thank you so much!

The javascript OTOH, does nothing. I placed a file called form_3.js into c:\xampp\apps\joomla\htdocs\components\com_fabrik\js\ Into that file I put:

JavaScript:
jQuery("#form_3 button[name = 'Goback']").attr('onclick', '');
jQuery("#form_3 button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=3";
    jQuery(location).attr('href',url);
});

The form ID is 3 and the url is identical to the one I used in the plugin. The "onclick" attribute of the "Goback" button is still wrong and points to the child form:

HTML:
<button type="button" class="btn button" 
onclick="parent.location='http://localhost/joomla/index.php/component/fabrik/details/4/67?Itemid='"
name="Goback" > 
Cancel</button>

Any ideas?

Best regards,
Arnor
 
I think that this button is from form with id=4
.... fabrik/details/4/67 ....
and may be need to change code to work for #form_4
 
Hi,

Form 3 has a child list on it (ID 4) which opens form 4. After that is done the Goback button URL points to Form 4 instead of List 3. It should redirect to ?option=com_fabrik&view=list&listid=3 just like the Save button plugin, which works perfectly.

If I put alert("test"); into the javascript code:

JavaScript:
jQuery("#form_3 button[name = 'Goback']").attr('onclick', '');
jQuery("#form_3 button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=3";
    jQuery(location).attr('href',url);
    alert("test");
});

it never shows the alert. I don't think it's loading the form_3.js file at all or there is something missing from it.

The documentation indicates that this method should add the javascript into the page header, presumably inside <script></script> tags:

"Adding Javascript to a Form Header (top)
Create a form_XX.js file in components/com_fabrik/js"

There is no reference of either the file or the actual code in the page header.

Best regards,
Arnor
 
Make file form_4.js with this code:
JavaScript:
jQuery("#form_4 button[name = 'Goback']").attr('onclick', '');
jQuery("#form_4 button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=3";
    jQuery(location).attr('href',url);
    alert("test");
});
 
Hi,

I'm sorry, this is convoluted and this should not be on form 4.

We have a parent list, list id 3. On the FORM for that list (form id=3), we have a list in the form's footer text: {fabrik view=list id=4}

List 4 only has a view form (detail) not an update form.

When I open form 3 and then open form 4 from the list in the footer of form 3, then go back from form 4 to form 3 and attempt to close form 3, the cancel button sends me to form 4 but needs to redirect to list 3. So the Goback button on form 3 needs to redirect me back to list 3. Please see: https://www.screencast.com/t/TIX5xEWa97 It shows this process and shows how the cancel button on form 3 goes back to form 4 instead of list 3. This process had BOTH form_3.js and form_4.js active with the alert. The alert() never showed and no redirection was applied to the Goback button.

My problem is that I never get any javascript loaded from those files, list_XX.js, form_XX.js etc. The js code does not appear in the source as <script></script> tags or as <script src="..."><script> tags. If I reduce both form_3.js and form_4.js down to a single
JavaScript:
alert("test");
it never shows up. Same with list_xx.js - they never seem to do anything, at least I see no evidence that anything in those files ever executes.

Best regards,
Arnor
 
Hi,

details_4.js was there also! Why should this be on form 4? It's the Goback button on form 3 that should be re-directing back to the list.

Best regards,
Arnor
 
I don't know where need to put code - on details_3.js, details_4.js. if your alert not run from nowhere try to clean your browser cashe.
 
Hi,

Will try that, thanks:) I have been trying to get js to run in Fabrik previously with the same results - nothing ever happened. Will keep poking at this! Thanks for your help, really appreciate it!

Best regards,
Arnor
 
If your list name Purchase Orders is list_3 and Purchase Orders form is form_3 then this is code in form_3.js:
JavaScript:
jQuery("#form_3 button[name = 'Goback']").attr('onclick', '');
jQuery("#form_3 button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=3";
    jQuery(location).attr('href',url);
    alert("test");
});
Note the id numbers of the form and the list. Not necessarily the same.
 
Hi,

This is what I have in form_3.js:

JavaScript:
jQuery("#form_3 button[name = 'Goback']").attr('onclick', '');
jQuery("#form_3 button[name = 'Goback']").on('click', function(){
    var url = "index.php?option=com_fabrik&view=list&listid=3";
    jQuery(location).attr('href',url);
    alert("test C:\\xampp\\apps\\joomla\\htdocs\\components\\com_fabrik\\js\\form_3.js");
});

As far as I can see, they are identical. I now KNOW that the code is being loaded as it threw errors on the alert using single backspace in the file path. However, the alert is never shown now and it does not set the redirection. I'll have to revisit this later - thanks for all the help:)

Best regards,
Arnor
 
Hi,

No, it's in the right folder and I FINALLY got this to work! This is what I had to use:

JavaScript:
    jQuery("button[name='Goback']").attr('onclick', '');
    jQuery("button[name='Goback']").click(function(){
      var url = 'index.php?option=com_fabrik&view=list&listid=3';
      jQuery(location).attr('href', url);
    })

When I looked at the html code I realized that fabrik is appending the record ID to the form ID, so instead of #form_3, I was getting #form_3_395, #form_3_396, etc. So I removed the #form_3. At that point I was using $ instead of jQuery and had other code in there that prevented it from working, but slowly I worked my way down to this and it WORKS!

Thank you so much for your help:)

Best regards,
Arnor
 
I don't know why I changed part of my code to jQuery("id=form_XX ....) instead of jQuery("[id*=form_XX] .....).
This was the correct code.
 
Hi,

I don't know why it is adding the row primary ID to the form id. Maybe there is a setting somewhere in Fabrik that is causing that, that I have accidentally turned on. What is important is that this works for my setup:)

Best regards,
Arnor
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top