Page 2 of 3

upgrade problem saving toggle val

Posted: Thu Feb 05, 2015 3:46 pm
by Ihor Didevych

Hi Michael,

You can try to map your toggle direct to the request parameter in the mapping, to avoid any coding


upgrade problem saving toggle val

Posted: Thu Feb 05, 2015 4:17 pm
by Michael4771079

Thanks Ihor,
the values I am using are not in the collection, the code was used to over ride the default values.

This is an upgrade to new builder and I need it to work in the same way as the published app.

Is the no way to over ride the default values of the all the toggles named "thin_deeptoggle" in a grid, in the new builder?

thanks


upgrade problem saving toggle val

Posted: Fri Feb 06, 2015 7:39 am
by Evgene Karachevtsev

Hello Michael,

Next lines will change all toggle components values for current screen
pre$(".ui-flipswitch-input option[value=off]").text("Sal")
$(".ui-flipswitch-on").text("Sal")

$(".ui-flipswitch-input option[value=on]").text("Che")
$(".ui-flipswitch-off").text("Chee")/pre


upgrade problem saving toggle val

Posted: Fri Feb 06, 2015 10:00 am
by Michael4771079

Hi Evegene,
Im afaid this approach wont work as on this page there are 2 toggles, more on other screens, for this reason the code that worked in old builder was specific to the toggle name, i.e "thin_depptoggle"

Here are my results,
I copied the code and ran it on page show, it changes the label on the toggle but not the value.

I altered the code to this but the result is it still the same, it saves the default toggle values "on and off"

$(".ui-flipswitch-input option[value=Chips]").text("Sal")
$(".ui-flipswitch-on").text("Sal")
$(".ui-flipswitch-input option[value=Salad]").text("Che")
$(".ui-flipswitch-off").text("Chee")


upgrade problem saving toggle val

Posted: Mon Feb 09, 2015 7:43 pm
by Evgene Karachevtsev

Michael,

You can't change value of the toggle, but you can use it to form your result
like this:
preif (Apperyio("mobiletoggle_61").val()) {
}/pre

OR
preconsole.log($(".ui-flipswitch-input option[value="+Apperyio("mobiletoggle_61").val()+"]").text());/pre


upgrade problem saving toggle val

Posted: Mon Feb 09, 2015 8:03 pm
by Michael4771079

Evegene,
do you mean I cannot change the toggle value from "on off" to another value like "chips and salad"

also I dont know where I would use the code above


upgrade problem saving toggle val

Posted: Mon Feb 09, 2015 10:22 pm
by Egor Kotov6832188

Hello Michael,
Yes, those values are hard coded, because of styles, classes and other logic in the component initialization, etc.

You can use above code on any events , page hide, before invoke any service - all depends on where you need toggler values.


upgrade problem saving toggle val

Posted: Mon Feb 09, 2015 10:43 pm
by Michael4771079

Hi Egor,

I just need to save a value "chips or salad" for the toggle depending on when it on or off,
the result is saved in an array in LSV and used in an email to send order
this is possible in old builder and works perfectly in published app.

Its very important within this app.
I dont want to upgrade this app but I do not have a choice,
appery wont support the old builder for long and apple will delist app on the 15th because of their requirements.


upgrade problem saving toggle val

Posted: Tue Feb 10, 2015 4:33 pm
by Evgene Karachevtsev

Michael,

Please try this code
pre// save all name in this array
var names = [ "name1", "name2","name3","name4"];

var result = [];
// push each value in temp array
for (var ind = 0 ; ind < names&#46;length; ind++ ){
result&#46;push($("&#46;ui-flipswitch-input option[value="+Apperyio(names[ind])&#46;val()+"]")&#46;text())
}

&#47;&#47; set your LSV from temp result array
Apperyio&#46;storage&#46;MY_LSV&#46;set(result);

&#47;&#47; NOW YOU CAN MAP YOUR LSV/pre


upgrade problem saving toggle val

Posted: Tue Feb 10, 2015 6:46 pm
by Michael4771079

Evegene,
I having trouble understanding this, sorry:(

where to run this code, on page show?

when you say "name1" do you mean the values I want for flipswitch
i.e flipswitch1 "name1 should be Chips and name2 Salad
flipswitch2 "name3 should be Garlic and name4 Chilli