how to use data-on-item-select

Get help with using Metro 4 components
Post Reply
elpepefontana
Posts: 3
Joined: Sat Apr 20, 2019 9:30 pm
Status: Offline

how to use data-on-item-select

Post by elpepefontana » Sat Apr 20, 2019 9:37 pm

Im trying to add behavior to a data-role="select", but i cant make the event data-on-item-deselect to run.

<select data-role="select" data-on-item-deselect="alert('try');">
........
</select>

I have tried to put the events in <option>, not working either.

I can use the "data-on-change" event ok, but "data-on-item-deselect" and "data-on-item-select" are not working?
I want to save "select".val() on a hidden field on "data-on-item-select" an to erase it with "data-on-item-deselect".

How can i make it work?

User avatar
olton
Site Admin
Posts: 233
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Sat Apr 20, 2019 9:38 pm

This work with select with attribute multiple

elpepefontana
Posts: 3
Joined: Sat Apr 20, 2019 9:30 pm
Status: Offline

Post by elpepefontana » Sat Apr 20, 2019 11:08 pm

I'm using it with a "multiple" select.
this is the code:

<select id="slt_3" name="slt_3" class="" data-role="select" multiple data-cls-option="fg-gray" data-on-change="setLevelSelect(3)" data-on-item-deselect="alert('try');">
</select>
Last edited by elpepefontana on Sat Apr 20, 2019 11:58 pm, edited 1 time in total.

User avatar
olton
Site Admin
Posts: 233
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Sat Apr 20, 2019 11:48 pm


elpepefontana
Posts: 3
Joined: Sat Apr 20, 2019 9:30 pm
Status: Offline

Post by elpepefontana » Sun Apr 21, 2019 1:15 am

Can't make it work....
It's a dinamic generated select, but all attributes are ok.
Will it be a difference if the select content is generated dinamically?
I'm doing its like this:
loop ------

var select = $('#slt_' + n).data('select');
select.data(out)

----- loop

The values Show OK.

User avatar
olton
Site Admin
Posts: 233
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Sun Apr 21, 2019 1:18 am

Create your code example on codepen.io or sandbox.org.ua

Post Reply