• Fabrik4.5.3 for J!5.3.0 and J!4.2+is out

    You must update from Fabrik4.5.1 if you are running Joomla!5.3.0

    See Announcements

Solved Copy List JS not working on copied elements

ontarget

Active Member
Fabrik 4.4.1 Joomla 4.4.8
Hi I have made a copy of List1 (I tried both methods below):
  • Copy list button (created a new set of form/groups/elements)
  • Add a new list and selected the existing database table.
I then tried accessing the new lists (Lists 2+3) via a menu and checked some of the submitted entries.

In List1 some of the elements have js on them to show hide stuff onload / on change
However in Lists2+3 the js dont have any effect.
Is there anything I missed?

The reason I need a copy of the list is i can't customise the CSV export in the menu.
 
I can't replicate.
JS is also on the new created (copied) elements and working.
Did you clear Joomla and browser cache?
 
Thanks, yes i cleared caches and still same issue.
I tried copying the list / groups / forms / elements again.
All my js is code rather than predefined actions, would that make a difference?
I cant see anything in the console - do you know of any method to see if the js is loading / firing when the copied form is loading or changing?

e.g onload
JavaScript:
var osVal = this.getValue();

var os_loc = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___overseas_location');
var ire_loc = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___location');
var os_dept_loc = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___departure_location');
var ire_dur = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___duration');
var ire_start = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___start_time');
var ire_fin = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___finish_time');
var os_depttime = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___departure_time');
var os_rettime = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___return_time');
var os_tra = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___flight_ferry_cost');
var os_traRec = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___flight_ferry_recipts');

os_loc.hide();
os_dept_loc.hide();
os_depttime.hide();
os_rettime.hide();
os_tra.hide();
os_traRec.hide();

if (osVal == 1) {
  os_loc.show();
  os_dept_loc.show();
  os_depttime.show();
  os_rettime.show();
  os_tra.show();
  os_traRec.show();

etc
 
Copied forms will have new form ids.
So if you are using hardcoded form/list/element ids you must adapt your code.
 
As i have about 300 elements with JS written directly into the JS text area of the element I'm wondering would changing:
var os_loc = Fabrik.getBlock('form_24').formElements.get('adtldldd_claim___overseas_location');
and replacing to
var os_loc = formElements.get('adtldldd_claim___overseas_location');
Still work?

That way i can do a find replace in the db table #_fabrik_jsactions and the copied elements will work as normal.
I'm going to test this anyhow!!
 
ok this works perfectly it seems.

var form = this.form; // Grabs the form block dynamically
var osVal = this.getValue();
var os_loc = form.formElements.get('adtldldd_claim___overseas_location');

That way i'm not hardcoding the form id into the elements making copying much easier.
 

Members online

No members online now.
Back
Top