Note that there are some explanatory texts on larger screens.

plurals
  1. POApply CSS/ javascript after jquery replaceWith
    primarykey
    data
    text
    <p>I'm replacing a row in a html table after a ajax request. After a successful request, I receive a partial html piece that I replace with the current row.</p> <blockquote> <p>$("#id").replaceWith(response)</p> </blockquote> <p>Now I added a checkbox input field and I pimped it using this css and js library <a href="https://github.com/nostalgiaz/bootstrap-switch" rel="nofollow">Bootstrap Switch</a></p> <p>So after I replace the row I only see a plain normal input checkbox. And not the nice toggle. If I refresh the page the toggle is rendered.</p> <p>Can anybody help me and point me to the problem of this issue? I tried to use trigger('create') on the row and the parent.</p> <p>This is the code I use for updating the table, like I mentioned it's only doing a replaceWith.</p> <pre><code>processRecord = (barCode, random_id) -&gt; postParams = { barCode: barCode, ran_id: random_id } $.ajax url: '/scans' type: 'post' data: postParams success: (response, textStatus, xhr) -&gt; $("#" + random_id).replaceWith(response) $("#scans").trigger('create') </code></pre> <p>I've been digging around the bootstrap switch code. The init method will cause additional html to be added to the input checkbox after rendering. This isn't happening when I do a replace. Take a look here: <a href="https://github.com/nostalgiaz/bootstrap-switch/blob/master/static/js/bootstrapSwitch.js#L14" rel="nofollow">https://github.com/nostalgiaz/bootstrap-switch/blob/master/static/js/bootstrapSwitch.js#L14</a> </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload