How to get to the value of the manipulated dom element using _this_ Jeditable?

This is a continuation of Jeditable: how to set parameters based on attributes of the dom element

Please answer here .. this is my real account.

I am trying to assign different parameter values โ€‹โ€‹to different divs on which I included the jQuery 'Jeditable' plugin. I canโ€™t make it work, Iโ€™m sure it is something simple .. but I canโ€™t figure it out.

How to get it?

Given the following DOM element:

<div class="editme" id="theone" rel="test"></div> 

These various snippets produce the following dafault placeholder texts for the above empty div:

 $('.editme').editable('savedata.php',{ placeholder : "txt - "+$(this), } ); // outputs: "txt - [object Object]" $('.editme').editable('savedata.php',{ placeholder : "txt - "+this, } ); // outputs: "txt - [object HTMLDocument]" $('.editme').editable('savedata.php',{ placeholder : "txt - "+$(this).html(), } ); // outputs: "txt - undefined" $('.editme').editable('savedata.php',{ placeholder : "txt - "+$(this).attr('rel'), } ); // outputs: "txt - undefined" $('.editme').editable('savedata.php',{ placeholder : "txt - "+this.attr('rel'), } ); // outputs: "" (NULL / EMPTY STRING, must be due to error) 
+4
source share
1 answer

Unfortunately, when you use this in your code, it refers to a collection of parameters, not the jQuery object that you are trying to access. To accomplish what you are trying to do, you will need a reference to the jQuery object outside the parameter collection.

Sort of:

 $('.editme').each( function() { var rel = $(this).attr('rel'); $(this).editable('savedata.php', { placeholder : "zzz" + rel, } ); }); 
+12
source

All Articles