Page 1 of 2

How to assign Event & Action for "select menu" component

Posted: Mon Sep 03, 2012 4:54 am
by John4930205

I thought this would be a basic process, but I can't seem to find any info on how to assign events & actions for each of the drop down items after creating a "select menu" component.

Do you know of any tutorial page or simple explanation on how to do this? Thx!


How to assign Event & Action for "select menu" component

Posted: Mon Sep 03, 2012 5:01 am
by maxkatz

Events are assigned to the component itself (Select Menu), not to individual values. Simply select the component, then add any available event (Events tab) and then add any available action. For example, you can use Value Change can be used when a new value is selected. Hope this helps.


How to assign Event & Action for "select menu" component

Posted: Mon Sep 03, 2012 5:16 am
by John4930205

I added Value Change and applied a custom javascript to the "select menu" component. It runs the same custom javascript for all the drop down items... How do I assign a specific custom javascript to a specific drop down item? Do I need to Set Property or Set Local Storage Variable?


How to assign Event & Action for "select menu" component

Posted: Mon Sep 03, 2012 5:47 am
by maxkatz

Check the value and run different code, you can use if-statement. This is how the Select Menu component works in the browser (nothing to do with Tiggzi builder).


How to assign Event & Action for "select menu" component

Posted: Tue Sep 04, 2012 5:01 am
by John4930205

I'm using "Value Change" and trying to check the value and run a code using if statement. I am not sure if I am setting the variable correctly below. Is this how you set a variable for Select Menu?

var myVar = Tiggr('mobileselectmenu1');

if (myVar == "vici"){

do something here...

} else {

do something else here...

}


How to assign Event & Action for "select menu" component

Posted: Tue Sep 04, 2012 5:35 am
by maxkatz

code
Tiggr('mobileselectmenu1');
/code

or

code
Tiggzi('mobileselectmenu1');
/code

returns a reference to jQuery Mobile component (http://help.gotiggr.com/documentation.... To get the value you need to do:

code
Tiggzi('mobileselectmenu1').val();
/code

When you run custom JavaScript, the component on which the event is invoked is passed as an argument (this), so you can also use this code:

code
$(this).val();
/code


How to assign Event & Action for "select menu" component

Posted: Wed Sep 05, 2012 3:23 am
by John4930205

Thank you Max! This is exactly what I needed! Solved.


How to assign Event & Action for "select menu" component

Posted: Fri Oct 26, 2012 8:08 am
by Haim

If I want to initialize the selection (let's say upon screen load) to some localStorage variable, how do I set it?

Let's say I have two settings with values "A" and "B"...

can I use something like:

$(this).val = 'A';

or what would I use?


How to assign Event & Action for "select menu" component

Posted: Fri Oct 26, 2012 8:35 am
by Haim

I should add that I also tried setProperty and that didn't seem to work.


How to assign Event & Action for "select menu" component

Posted: Fri Oct 26, 2012 8:54 am
by Maryna Brodina

Hello! Try next:

Tiggr('selectMenu').append(""+"Something"+"") - edding element to dropdown

Tiggr('selectMenu').selectmenu("refresh"); - refresh dropdown after you add element