1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

How to append a single option to a dbjoin element

Discussion in 'Community' started by mirceat, Jan 12, 2018.

  1. mirceat

    mirceat Member

    Level: Community

    I need to add a single option to a dbjoin element, below default "Please select" option. I can't use the "Eval option" because i'm using placeholders in Where statement and the placeholder value should be updated via AJAX.

    So, what i need is to have something like this in a dbjoin element rendered as dropdown:

    <option value="0">Please select</option>
    <option value="1">Others</option>
    rest of dynamic options here
    Thank you
  2. mirceat

    mirceat Member

    Level: Community
    friendly bump..

    Please note that i tried to add the option using jquery (prepend) but then the option is displayed multiple times, i need to display it only once after "Please select".

    Code (Javascript):
    $("mytable___my_element").prepend('<option value="1">TEXT</option>');

    Thank you
    Last edited: Jan 16, 2018
  3. Bauer

    Bauer Well-Known Member

    Level: Supporter
    The key to making that work would be to be certain you have a row in the table used by the database element that has the PK value (id) of 1 and the text you want to display.

    This assumes the dbj options are ordered by 'id', which is the default. (i.e. there is no ORDER BY included in the 'Joins where and/or order by statement (SQL)' configuration of the dbj 'Data - where' tab.)

    Then, if you want that TEXT value to be dynamic, you would have to modify it using javascript. e.g. ...
    Code (Javascript):
    var myText = "Text used for option 1";
    JQuery("#mytable___my_element option[value=1]").text(myText);
    Also - if needed, put an OR condition in your WHERE condition to be sure '1' always gets included in the options.

Share This Page