Skip to content

cannot apply prettyCheckable to elements loaded via ajax call #87

@dcalmbach

Description

@dcalmbach

Hi,
first of all many thanks for your great looking plugin.

Now my problem:

I load a document with several table rows like this

<tr id="tr4545" class="odd">
    <td><input type="hidden" name="_bekannt" /><input
        type="checkbox" name="bekannt" checked="checked" value="85"
        onChange="cbClick(event, this,4545);" id="bekannt" /></td>
    <td style="text-align: right">1</td>
    <td style="text-align: right"></td>
    <td>Also hat Gott die Welt geliebt</td>
</tr>

In the document.ready section i apply checkable like this:

$(":checkbox").each( function(){ $(this).prettyCheckable()})

and everything works fine.

When the checkbox is clicked, the table row is reloaded via ajax:

function check(liedId) {
    var rowId = "#tr" + liedId;
    $(rowId).load("/lied/lied/check", {
        id : liedId
    }, new function() {
        formatRowElements(rowId);   
});

on ajax completion i try the apply prettyCheckable the the new row:

function formatRowElements(rowId) {
    $(rowId + " select").addClass( "ui-corner-all ui-state-default");
    console.log($(rowId + " :checkbox"));
    $(rowId + " :checkbox").prettyCheckable();
}

But this does not work. I checked the log, the selector is working and shows the row.

Pls help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions