• 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.

executing element javascript on a repeating group


Active Member
on this repeating group form:
View attachment 17277
i have element javascript on 'who' that fires onChange. it looks up the hourly rate for the person selected (using index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=hourlyRateLookup&id=xxx which functions to return {"rate":40} for example.

my question is how do i write the javascript to fill in the id of the person selected for that row....
if this were on a normal form (not in a repeat group) , i would use:
var id = $('srms_work_order_labor___who_raw').value;
to get the value and set somethinglike $('srms_work_order_labor___cost').value = jsonResponse.rate;

but that doesn't work when i'm in a repeat group.

where would i find the id of the user that was changed (and the row number to be able to set the corresponding cost column).
i think i may have figured it out.
i think this.options.repeatCounter gives the current row number.
so this will figure out the id that was changed. and i can set the appropriate cost_'+rownum also.
works on added rows too.

var rownum = this.options.repeatCounter;
var id = $('srms_work_order_labor___who_'+rownum).value;
Couple of things ...

It's better to use the Fabrik element object update() and getValue() methods, rather than getting and setting the value attribute directly on the DOM object. There's a lot of elements that do "other stuff" when you get or set their values, or don't have a single 'value' to set / get.

And the best way to get the repeat num is with the getRepeatNum() method.

var id = this.form.formElements.get('srms_work_order_labor___who_' + this.getRepeatNum()).getValue();

Note that in this case, I'm using the reference to the form's block in the element object (this.form). You can also get that with the Fabrik.getBlock('form_X') method.

And ... if you are meaning to use jQuery, don't use $(), use jQuery().

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

Thank you.

Members online