When I uncheck an item I want it to be removed from the listview. Removing all items -not a problem. Neither is first item or last.
$("input[type = 'checkbox']").change(function(){
var item=$(this);
var elementName = $(item).attr('class');
if(item.is(":checked")){
$('#myTB').append($('<li>').attr('class','ui-li ui-li-static ui-btn-up-c ui-li-last').append('<label><input type="checkbox" name="checkbox" checked/>' + elementName + '</label>').attr('id', elementName));
} else {
$('#' + elementName).remove();
$('#myTB:visible').listview('refresh');
}
});
Cant seem to figure out what I'm doing wrong here.
HTML- at the point of the original "check"
<div id="checkboxes3" data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="vertical" data-mini="true">
<input id="checkbox8" name="addTo" data-theme="b" type="checkbox" class="Colgate Total Plus Whitening Toothpaste">
<label for="checkbox8"> add to </label>
</fieldset>
</div>
HTML dynamically updated listview - listview gets populated when checks are made to multiple items
<div data-role="content">
<ul id="myTB" data-role="listview" data-divider-theme="b" data-inset="true">
/* dynamically added */
</ul>
</div>
itemhave more than one class ?