Hardcopi
Hardcopi

Reputation: 21

How do I get the property of Kendo Mobile of checkbox?

I have a Kendomobile listview:

<li class="cycle">
<label><input type="checkbox" id="team3RedAssist">Assist Red</label>
</li>

I want to get whether it is checked and then be able to check it or uncheck it. On the web I can use something like:

$('#team3RedAssist').prop('checked');

to get the value. (or using attr) but for some reason this isn't working and using prop and attr to set it does nothing as well. I assume it is because of the styling, etc.

Upvotes: 1

Views: 80

Answers (3)

knikolov
knikolov

Reputation: 1800

This seems to work for me (using jQuery prop): http://trykendoui.telerik.com/eYUg

Upvotes: 0

Muthu
Muthu

Reputation: 780

Try this,

In html page:

<div data-role="view" id="customers" data-title="My Data">
    <ul data-role="listview" id="MainListView">
     <li class="cycle">
         <label><input type="checkbox" id="team3RedAssist" />Assist Red</label>
     </li>
    </ul>
</div>

In javascript:

$(function(){

    var app = new kendo.mobile.Application($(document).body);      

    $('#MainListView').bind('click', function() {
           alert($('#team3RedAssist').prop('checked'));
    });

});

You could use above alert function wherever you want.

For online demo click here

Upvotes: 0

Petur Subev
Petur Subev

Reputation: 20193

I suspect that you are using remote binding and the checkbox in the template is still not created. Try to execute that logic inside the dataBound event of the listview.

Also using id inside template is not a good idea. There will be multiple elements with the same id.

Upvotes: 1

Related Questions