Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
Accepted Solution

JQMobile - uncheck with Javascript

I've made a JQMobile checkbox like so...

 

<label><input type="checkbox" name="checkbox" id="checkbox"/> Label</label>

 

I want to use Javascript to uncheck the box. 

 

I've tried the script normally used for unchecking checkboxes with jquery

 

$('input[name=checkbox]').attr('checked'false);

 

I've also tried using a piece of code I found on the jQuery Mobile website ( http://jquerymobile.com/test/docs/forms/checkboxes/methods.html )

 

$("input[type='checkbox']").checkboxradio('disable');

Neither methods seem to work.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Contributor
Gerii
Posts: 33
Registered: ‎04-30-2012
My Device: PlayBook, DevAlpha

Re: JQMobile - uncheck with Javascript

You have to refresh every UI component in jQueryMobile if you change its state via JavaScript. In this case the code should look like this:

$("input[type='checkbox']").attr("checked",false).checkboxradio("refresh");

 

Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook

Re: JQMobile - uncheck with Javascript

Went to http://blackberry.github.com/jQueryMobile-BB10-Theme/kitchenSink/checkboxes.html

Turned on Ripple Emulator. Checked a box. Then opened the Javascript console and pasted your suggested code.

It returns ...

TypeError: Object [object Object] has no method 'checkboxradio'
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook

Re: JQMobile - uncheck with Javascript

It seems the problem is actually something to do with the Ripple Emulator.

https://github.com/blackberry/jQueryMobile-BB10-Theme/issues/76#issuecomment-11537132
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis