NicolasCARPi / jquery_jeditable

jQuery edit in place plugin. Extendable via plugin architecture. Plugins for plugin. Really.
https://jeditable.elabftw.net
MIT License
1.74k stars 458 forks source link

Dynamic table not workin #221

Closed Chris-Pyro closed 4 years ago

Chris-Pyro commented 4 years ago

Hey I have a html table that i cant edit with jeditable with no issues. BUT if i use my button to add another row to the table dynamically it isnt editable at all. how to i add the editable functionality to a dynamically created row?

Cant upload my Code due to workplace rules unfortunately but basically it's as follows:

Create a html table that gets filled with values from a database and is editable. add a button to Bottom of page to add a row using a bit of JavaScript. button add row (same layout and all) but it is not editable anymore. the previous rows still work fine.

Expected result

Add row to table and be able to edit it.

Actual result

Added row isnt editable.

Environment

jQuery version: 3.4.1 Browser: MS Edge (Ik but as said workplace rules :/ ) OS: Windows 10

NicolasCARPi commented 4 years ago

You can use something like:

$(document).on('mouseenter', '.editable', function() {

To bind the .editable to your element not on page load but once the mouse is over it. Basically you need to make sure the listener is here at all time (like document), as jeditable cannot bind to dynamically created elements.

If your company is using jquery-jeditable, please consider becoming a Github Sponsor ;)

Chris-Pyro commented 4 years ago

Does that work with different editables though? i use timepickers, charcounters and textareas. Also it doesn't seem to work at all if I change

§(document).Ready(function (){

to your snippet. Table just breaks :(

Chris-Pyro commented 4 years ago

nevermind my last comment it works perfectly. Thank you so much I've been looking everywhere for a solution. :DDD