frequent
frequent

Reputation: 28523

How to enhance a dynamically created Jquery Mobile checkbox?

I'm struggling to get this to work:

var selectorBox = $('<label for="'+selectorID+'"><input type="checkbox" id="'+selectorID+'" name="'+selectorID+'" class="selector" data-inline="true" data-iconpos="notext"></label>').trigger('create'),
    cell = $( "<th class='persist essential notxtchkbx rowHigh' "+rowSpanner+"></th>" ).append( selectorBox );

currentRow.prepend( cell );

selectorBox is the checkbox HTML, which I'm trying to enhance by trigger("create") before creating a cell and inserting this cell in a table row.

Question:
How do I get this checkbox to render properly?

Thanks for help!

Upvotes: 0

Views: 837

Answers (1)

frequent
frequent

Reputation: 28523

To enhance a checkbox you will need to call trigger("create") on its parent element. Calling it directly on the checkbox does not work. Just use something like:

$("input.myCheckbox").closest("div").trigger("create");

And it should work.

Upvotes: 1

Related Questions