Page 1 of 1

how to get the selected item index from a list?

Posted: Mon Aug 05, 2013 3:07 am
by Pasteur Miranda

Hi,

Code: Select all

How to get the selected item index from a list? 

Thank you


how to get the selected item index from a list?

Posted: Mon Aug 05, 2013 3:12 am
by maxkatz

how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 12:46 am
by Pasteur Miranda

Hi Max,

Thank you for your answer, but I need to get the selected item in the list, in order to show it in the next page. The tutorial does not access the selected item index.

Code: Select all

Thank you very much,

how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 12:49 am
by Pasteur Miranda

As a complement to my last reply I need to invoke the listview click event and, inside it, get the selected item index.

Thanks


how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 1:07 am
by Igor

Hi,

Next code should help:
precode
Appery("mobileselectmenu_44").find(":selected").index();
/code/pre

Please change your component name.


how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 1:08 am
by maxkatz

Check the generate code, I think the index should be in the element. If yes, you can read it. If not, you would need to add a custom attribute that holds the index of the item.


how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 1:37 am
by Pasteur Miranda

I think this should work to select menu widget, but I tried to listview and it returns only the index -1. Any other suggestion?

Code: Select all

Thank you all.

how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 3:51 pm
by Pasteur Miranda

Hi,

Code: Select all

Do you have any other suggestion? Isn't it possible to get the selected item index from listview as you get it from select menu? 

Thank you very much.


how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 4:28 pm
by Oleg Danchenkov

Hi, Pasteur.
Add Run JavaScript action on click event on mobileList with this code
alert($(this).find("li:not([_tmpl=true])").index($(arguments[0].target).parents("li")));


how to get the selected item index from a list?

Posted: Wed Aug 07, 2013 10:15 pm
by Pasteur Miranda

Hi Oleg,

Thank you very much, this code worked!

Again, your support and application builder is amazing. Congratulations!