Hi, I have a media-list that changes to checkboxes on taphold. I put this code to convert <a>
items into <label>
items. The code works fine but the checkboxes doesn’t get checked when I click on them. Maybe I need some kind of refresh? Thanks!
if (device.platform == 'browser') {
// Taphold doesn't work on browser
$viewDiv.on('contextmenu', 'a', taphold);
} else {
$viewDiv.on('taphold', 'a', taphold);
};
function taphold(e) {
var $list = $(this).closest('div.list');
if ($list.hasClass('media-list')) {
$get('.media-list a').replaceWith(function () {
var $label = $('<label/>', {
class: 'item-checkbox item-content',
});
$('<input/', {
type: 'checkbox',
value: 1,
}).appendTo($label);
$('<i/>', {
class: 'icon icon-checkbox',
}).appendTo($label);
$label.append($(this).contents());
return $label;
});
};
};
Example list:
<div class="list media-list chevron-center" style="margin-top: 0;">
<ul>
<li doc_id="381910">
<a href="#" class="item-link item-content">
<div class="item-inner">
<div class="item-title-row">
<div class="item-title">My title</div>
</div>
<div class="item-subtitle">My subtitle</div>
</div>
</a>
</li>
</ul>
</div>