4

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

I am loading content via ajax that needs to have the ability to tie into the .editable() functions on the parent page. I am not finding much in terms of documentation that addresses this. I think I must be blind or sumthin'.

How do I get this .editable to work when trying to access it via ajax live loaded content:

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

Thanks so much for your help!!!

2 Answers 2

2

Among the options there is a parameter called selector

More info here http://vitalets.github.io/x-editable/docs.html#editable

This would delegate editable to the targets even after they've been added to the DOM after load.

1
  • That's the best answer!
    – bart
    Commented Jan 23, 2014 at 8:27
0

Im not sure if this is the best approach, but for the sake of not being able to find a better solution, this is what I have come up with:

I created a function to contain my editable script such as this:

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

Then when ever I need to activate my editables on the page, whether after an ajax call or a page load I just call the name of the function: myEditables();

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.