0

I save a text with Jquery/Ajax method. I use an edit-in-place script (Jeditable) which allows to edit text by clicking on it. Unfortunately, Jeditable script doesn't work on dynamically created items, it works only when I reload the page.

this is my script:

$(".edwa").editable("/edit.php", { 
indicator:"<img src='/images/loading.gif'>",
width:439,
height:90,
loadurl:"/load.php",
type:"textarea",
onblur:"submit"
});

In a similar situation I fixed the problem by adding "$(document.body)" to the script but in this case I don't know what will be the correct syntax to add "$(document.body)". Any ideas or any other suggestions to solve the problem?

user
  • 751
  • 2
  • 10
  • 18
  • Run the code shown _after_ the dynamically added items have been added. – nnnnnn Feb 27 '14 at 13:08
  • I'd try the `.find()` function, like `$(document).find('.target')` – Kevin Cittadini Feb 27 '14 at 13:11
  • Simply using `.on('click', ...)` does not work in jQuery 1.7+ anymore. Check this for a solution http://stackoverflow.com/questions/15090942/jquery-on-method-not-working-on-dynamic-content – Sliq Aug 15 '14 at 06:07

3 Answers3

1

after a partail upload happens, you have to recall javaScript functions again to apply them to new created elements.

$(document).ready() only executes for full page load;

maybe this solve your problem :

<script type="text/javascript">   function pageLoad() {
               $(".edwa").editable("/edit.php", { 
                  indicator:"<img src='/images/loading.gif'>",
                  width:439,
                  height:90,
                  loadurl:"/load.php",
                  type:"textarea",
                  onblur:"submit"
               });
             }
</script>

and you have to call pageLoad() function each time you do a partial update using ajax.

SalmanShariati
  • 3,752
  • 4
  • 24
  • 45
0

You should re-run the initialization of your plugin after dynamicaly loading your elements.

Fernando Rybka
  • 238
  • 1
  • 4
  • 14
0

Bind your editable function after creating your dynamic element

Siddharth Nagar
  • 396
  • 1
  • 13