- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
I am still learning and working on Intel XDK platform.
I was switch multipage applications trials.
My project in has two pages, These are #mainpage and #settings
Main page in click settings button go to the #settings page. This page has radiobox language switch button.
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Select Your Language:</legend>
<input name="selectLang" id="radio-choice-h-2a" value="en" checked="checked" type="radio">
<label for="radio-choice-h-2a">English</label>
<input name="selectLang" id="radio-choice-h-2b" value="ru" type="radio">
<label for="radio-choice-h-2b">Russian</label>
</fieldset>
And I am controlling in app.js follow here;
window.currentLanguage = "en";
$(document).ready(function(){
//Language Init
if(window.currentLanguage == "en"){
$('input[name=selectLang][value=en]').attr("checked",true);
$('input[name=selectLang][value=ru]').attr("checked",false);
}else{
$('input[name=selectLang][value=en]').attr("checked",false);
$('input[name=selectLang][value=ru]').attr("checked",true);
}
//It is working
alert($('[name="selectLang"]').val());
//It is not working
$('[name="selectLang"]').click(function(){
alert($(this).val());
});
});
I don't understand. Where is the problem? I had try .on and .delegate method but this situation is same.
Thank you for interest.
Good works.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For checkboxes you use .prop("checked", true), not .attr()
http://stackoverflow.com/questions/15044340/jquery-set-checkbox-checked
And to change a value and have an event fired, you use $(domNode).val() and for knowing when that has changed $(domNode).change()
https://api.jquery.com/change/
Hope these help,
Chris
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page