var tableName = "<%= params[:table] %>"; var snaptable = $(".snaptable." + tableName); snaptable.replaceWith('<%= j content %>'); snapifyTable($(".snaptable." + tableName));