w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

checkbox group and checkbox item behaviour

Found 1 answer: You have to select a single checkbox like this: Tiggzi("chkItem").find("input[type='checkbox']")

So this is solved. But 1 issue that remains, is the fact that the value change event is called 2 times. This gives problems when using a counter, or a .toggle() in the value change event.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

checkbox group and checkbox item behaviour

Hi,

Let's start by order.

  1. It's our bug, we'll fix it.

    2, 3. In JQM logic, checkbox is an invisible HTML component and its appearance: a tick and a Label. That's why the following line:
    codeAppery('chkItem');/codedoesn't return component but span component that is created by JQM library for setting custom appearance.

    Component span does not have "checked" property. So the following line:
    codeAppery('chkItem').prop('checked')/codealways returns "undefined".

    You should use:codeAppery('chkItem').find('input').prop('checked')/codeorcodeAppery('chkItem').find('input').is(':checked')/code/span/span

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

checkbox group and checkbox item behaviour

Thank you Katya! You saved my afternoon work :)

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

checkbox group and checkbox item behaviour

Glad I can help :)

Avinash Lt
Posts: 0
Joined: Mon Dec 24, 2012 11:57 am

checkbox group and checkbox item behaviour

need an array of items with true or false to determine if the item is checked or not

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

checkbox group and checkbox item behaviour

Hi,

Use the following:
codevar checked_values = $.map( Appery( "mobilecheckboxgroup_17" ).find( ":checked" ), function(e){ return $(e).val(); } );/code

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

checkbox group and checkbox item behaviour

given this code below to read the collection of elements in a checkbox group, how would I set it from localStorage?

//Reading
var DOW1 = $.map( Appery( "Alarm1DOW" ).find( ":checked" ), function(e){ return $(e).val(); } );

localStorage.setItem("DOW1", DOW1);

//Writing
var DOW1 = localStorage.getItem("DOW1", DOW1);
$.map( Appery( "Alarm1DOW" ).find( ":checked" ), function(e){ return $(e).val(DOW1); } );

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

checkbox group and checkbox item behaviour

I adapted my code from the select to the checkbox, but it doesn't seem to fire:

function SetDow()
{
//DOW
var DOW1 = localStorage.getItem("DOW1");

//Now set DOW1
var selectedValues;
try {
selectedValues = JSON.parse(DOW1);
if ({}.toString.call(selectedValues) !== "[object Array]")
{
selectedValues = [];
}
} catch ( e )
{
selectedValues = [];
}

Appery("Alarm1DOW").find(":checked").each(function()
{
var $this = $(this)
if (selectedValues.indexOf($this.prop("value")) != -1)
{
$this.prop("checked", true);
}
else
{
$this.prop("checked", false);
}
})
Appery("Alarm1DOW").selectmenu("refresh");

}

Return to “Issues”