Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Dynamically creating Radio options

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.

Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

Thanks alot!! Everything is working now )

Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

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.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Dynamically creating Radio options

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.

Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

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

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Dynamically creating Radio options

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?

Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

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)

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Dynamically creating Radio options

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

Slava Balabanov
Posts: 0
Joined: Thu Apr 17, 2014 4:35 pm

Dynamically creating Radio options

Thank you very much for the help. Appreciate it

Return to “Issues”