Page 2 of 2

Dynamically creating Radio options

Posted: Sat Apr 19, 2014 1:48 pm
by Slava Balabanov

Thanks!
There it is:
http://appery.io/app/mobile-frame?src...

Just press Register.. its the screen there..
The radio buttons should be under "Your food preference"
Also, for some reason i put only 3 items in the array but there are 4 radio buttons generated


Dynamically creating Radio options

Posted: Mon Apr 21, 2014 4:51 am
by Illya Stepanov

Hi Slava,

Your problem is just invoking your service on the "Page load" event.

But you should do it on the "Page show" event.

This issue causes because of your service code is not async and iterating processing does before init component processing.

That's all.

Regards.


Dynamically creating Radio options

Posted: Mon Apr 21, 2014 9:36 am
by Slava Balabanov

Thanks alot!! Everything is working now )


Dynamically creating Radio options

Posted: Mon Apr 21, 2014 11:01 am
by Slava Balabanov

OK so now everything is working except for 1 thing =]
I now need to know what checkbox / radio button is checked to use them..
So, as the tutorial states and naturally i've added "value changed" events for both the radio boxes and the check boxes that i populate (the group itself).
The strange thing is: the event fires on the radio box, but doesnt fire on the checkbox.
Same screen. The radiobox name is: "foodTypeRadio" and the checkbox name is: "spcialFoodCheck"
I've seen a thread that states that there was a bug related to the value changed event but the thread was old (a year ago) so i'm assuming that it was fixed already.


Dynamically creating Radio options

Posted: Tue Apr 22, 2014 2:33 am
by Illya Stepanov

Hi Slava,

Please follow these steps:
ol
liRemove or comment your current event handlers for these components (radiogroup and checkgroup)/li

li Select checkbox_group(don't only one item you should select whole group) and create JS event handler on "value change" event./li

li Insert the following code:
precode
//You should "mobilecheckboxgroup_16" with your checkboxgroup name.
var checkedBoxes = Appery("mobilecheckboxgroup_16").find("input:checked");

for(var i = 0; i < checkedBoxes&#46;length; i++){
var checkedBox = jQuery(checkedBoxes);

Code: Select all

 &#47;&#47;Using current checked items&#46; You can check it out in the browser console&#46; 
 &#47;&#47;Also you need to implement using you need&#46; 
 console&#46;log("selected [" + i + "] checkBox = " + checkedBox&#46;val()); 

};/code/pre/li
liSelect radio_group (don't only one item you should select the whole group) and create JS event handler on "value change" event. http://prntscr.com/3c8qus/direct/li

liInsert the following code:
precode
&#47;&#47;You should "mobilecheckboxgroup_16" with your radioboxgroup name&#46;
var checkedBoxes = Appery("mobileradiogroup_12")&#46;find("input:checked");

&#47;&#47;Note this code is needed only for analogic with checkboxes&#46;
&#47;&#47;Cause of only one radiobutton could be checked within one group&#46;
for(var i = 0; i < checkedBoxes&#46;length; i++){
var checkedBox = jQuery(checkedBoxes);

Code: Select all

 &#47;&#47;Using current checked items&#46; You can check it out in the browser console&#46; 
 &#47;&#47;Also you need to implement using you need&#46; 
 console&#46;log("selected [" + i + "] radio = " + checkedBox&#46;val()); 

};/code/pre/li
/ol
That's all. As you can see we are suggest you an equal code for the checkboxes and radiobuttons. And the way to implement is equal too.

Regards.


Dynamically creating Radio options

Posted: Tue Apr 22, 2014 12:26 pm
by Slava Balabanov

Thanks but it didnt help me.. i'll exaplain.
The problem is not with the code itself, the problem is that the event for "value changed" is not firing from the checkbox group. It only fires on Radio Group.
That is the code from the HTML:
pre
code
$(document)&#46;off("change", '#Register_registerContainer [name="spcialFoodCheck"]')&#46;on({
change: function() {
var checkedBoxes = Appery("spcialFoodCheck")&#46;find("input:checked");
for (var i = 0; i < checkedBoxes&#46;length; i++) {
var checkedBox = jQuery(checkedBoxes);
&#47;&#47;Using current checked items&#46; You can check it out in the browser console&#46;
&#47;&#47;Also you need to implement using you need&#46;
console&#46;log("selected [" + i + "] checkBox = " + checkedBox&#46;val());
};
},
}, '#Register_registerContainer [name="spcialFoodCheck"]');
};
/code
/pre

Where "spcialFoodCheck" is:
pre
code
<div id="Register_spcialFoodCheck" class="Register_spcialFoodCheck ui-field-contain" dsid="spcialFoodCheck" data-role="fieldcontain">
<fieldset class="ui-controlgroup ui-controlgroup-vertical ui-group-theme-d ui-corner-all ui-mini" data-mini="true" data-theme="d" data-role="controlgroup">
/code
/pre

It doesnt reach there, ever... no idea why.
I have the same code in the radio group but there it triggers. No idea why is that :S


Dynamically creating Radio options

Posted: Wed Apr 23, 2014 12:03 am
by Igor

Hello,

Before post this solution we tested it and it worked. It could be that your app logic is different. Can you share your app with us?


Dynamically creating Radio options

Posted: Wed Apr 23, 2014 5:40 am
by Slava Balabanov

Hi,
I've shared the app. Its called "Plate-O".
The relevant page is the "Register" page. There are 2 groups, radio and checkbox. The checkbox is what acting strange.
I've added labels that should have a text set into them stating what is chosen here. The label for the radio updates correctly, but the lower once for the checkbox doesnt change (the code that changes it now commented out as you requested)


Dynamically creating Radio options

Posted: Wed Apr 23, 2014 8:34 am
by Maryna Brodina

Hello!

Unfortunately there is a bug, we will fix it. As a workaround you can add event manually. On event "Page show" create the following code:pre$&#46;mobile&#46;activePage&#46;off("change", '[name^="mobilecheckboxgroup_2"]')&#46;on({
change: function() {
alert('unstandart change');
},
}, '[name^="mobilecheckboxgroup_2"]');

&#47;&#47;where mobilecheckboxgroup_2 name of your checkbox group/pre


Dynamically creating Radio options

Posted: Thu Apr 24, 2014 2:39 pm
by Slava Balabanov

Thank you very much for the help. Appreciate it