Access to a list filter using javascript

rdiana

Member
LIST and Form together: access to a list filter from a FORM button

Dear friend,
I've an article which includes (through the content plugin) both a list and a particular form, this one including some button plugin elements (button 1, button 2...). Moreover, some elements of the list are used as dropdown type filters (see attached figure).
The problem: when I push a button, the related javascript code should read the filter field value (let's say "Attivit?") to perform an action.

How can I reference the list filter from javascript included in the form button?

The field element, used ad dropdown filter, is act_id of the temp_report group: on the click event of the button plugin I've attached the following code :

alert($('temp_report___act_id').value);

but nothing happens (of course the command alert is used only as a proof). How to solve?
Thank you for your attention.
Cheers,

Roberto
 

Attachments

  • form-list.jpg
    form-list.jpg
    47 KB · Views: 286
The main Fabrik global object contains everything Fabrik related on your page.

In this case, what you'll be looking for is Fabrik.blocks.list_X_com_content_X (where X is your numeric list ID). That in turn contains a 'form' object, which includes all the current filter settings.

So, use Firebug (or developer tools in Chrome or IE, depending which you prefer), and examine those objects, which should show you what you need to know.

-- hugh
 
Hi Hugh,
many thanks for your assistance. I've attached the firebug output relevant the filter element ("attivit?"): can you give me some further info to get the filter element? how can I write the javascript statement to read the filter value?

Thanks again.

Roberto
 

Attachments

  • firebug.jpg
    firebug.jpg
    61.7 KB · Views: 277
That's not the Fabrik JS object, that's the DOM structure. But that'll work, if all you want to do is read a value.

Just 'inspect' it, copy the ID of the filter element you want, and grab the value ...

Code:
var val = $('temp_report___act_idvalue).value;

-- hugh
 
Ok Hugh, it works fine and I've understood the concept!
Thank you again very, very much!! ;)

Have you a nice day,

Roberto
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top