How to get x-editable for working with ajax content

I have a question about the loaded content of ajax and .editable ();

I am uploading content via ajax, which should be able to bind to the .editable () functions on the parent page. I do not really understand the documents that relate to this. I think I should be blind or crazy.

How can I get this .editable to work when trying to access it through the downloaded ajax content:

$('#charge_name a').editable({ // scripts here... }); 

Many thanks for your help!!!

+4
source share
2 answers

Among the parameters there is a selector parameter

More details here http://vitalets.imtqy.com/x-editable/docs.html#editable

This will delegate editable goals even after they are added to the DOM after loading.

+2
source

I'm not sure if this is the best approach, but in order to not find a better solution, this is what I came up with:

I created a function that contains my editable script, such as:

  function myEditables(){ $('#charge_name a').editable({ // scripts here... }); } 

Then, when I ever need to activate my editable pages, whether after calling ajax or loading the page, I simply call the function name: myEditables ();

If anyone knows a better way, please let me know, I would be more than grateful. Thanks!

0
source

All Articles