Sending parent id as parameter in jEditable

Considering

$(".foo").editable("script.php") 

How to pass .foo parent id as parameter? I tried

 $(".foo").editable("script.php", { submitdata: { parent_id: $(this).parent().attr('id') } }); 

and every option I can think of, but it just seems like the $ (this) object is not working in this context.

+4
source share
3 answers

I had the same problem, the following solution was found here:

 $('.jeditable').each(function() { var $this = $(this); $this.editable('submit.jsp', { submitdata : { parent_id : $this.parent().attr('id') } }); }); 
+15
source

You can make an Ajax call so that you can pass everything (if you are looking for the future, maybe you are going to add a few functions ..).

Example:

 $('.edit').editable( function(value, settings) { // prepare the data, add all parameters you want var data = "param1=value1" + "&param2=value2"; var ret = ""; // make the ajax call to do the work (not async) $.ajax({ type: "POST", url: "page.php", data: data, async: false, success: function(msg) { if (msg.length != 0) { // set the value to write in the element ret = msg; } } }); // return the element to save into the element return ret; }, { // set the jeditable setting cssclass: 'classname' } ); 

I think this method is more flexible to handle all cases.

0
source

I would just do this:

$(".foo").editable("script.php", { submitdata: { parent_id: $(".foo").parent().attr('id') } });

You also have a typo in your question, you have $ (. Foo) .editable () instead of $ (". Foo"). editable (). If this is also in your actual code, this could be the source of the problem.

-1
source

All Articles