Jeditable: how to set parameters based on dom element attributes

Often I find that I need to use jeditable in several areas that require different parameter settings.

For example, I use jeditable with the autosuggest input type, and then I need to transfer different data sources to different inputs.

I wanted to use only one instance of the editable plugin and tried to assign attr values ​​to the script, but obviously this does not work the way I approach it.

I hope someone can tell me a little ..

Essentially, I would like to set the jeditable value based on the ttribute value of the dom element it is manipulating.

sort of:

$('.editme').editable('savedata.php',{ loadurl : 'loaddata.php', loaddata : { handle: $(this).attr('rel') } }); 

then I could just point out different download sources with:

 <div id="fruits" class="editme" rel="myfruits">apples</div> 

I did not find the this keyword to work this way.

How can I access the attributes of a dom element that is dynamically controlled for each jeditable binding?

Here is another example of what I want to do: authorsList = ".split (", ");

  // extend jeditable with autocomplete $.editable.addInputType('autoc', { element: function(settings, original) { var input = $("<input />").autocomplete(settings.mdata, settings.autoc); $(this).append(input); return input; } }); $('.editable.authors').editable('savedata.php',{ type : "autoc", mdata : $(this).attr('rel'), // should hold the name 'authorsList' onblur : 'ignore', autoc : { multiple: true, multipleSeparator: ',' }, loadurl : 'loaddata.php', loadtype : 'POST', loaddata : {handle: function(){ return eval($("#objhandle").val())}, lookuptype: 'mirror'}, submit : 'save', cancel : 'cancel', tooltip : "Click to edit", style : "inherit", cssclass : 'jedi', id : "field", name : "data", submitdata : { storetype: 'mirror', handle: function(){return eval($("#objhandle").val())}, timestamp: function(){return eval($("#objtimestamp").val())} } }); 
+2
source share
2 answers

Warning, completely untested code, but something like the following should work:

 $('.editme').each(function() { $(this).editable('savedata.php',{ loadurl : 'loaddata.php', loaddata : { handle: $(this).attr('rel') } }); }); 

Therefore, an assessment of this should be correct when initializing the Jeditable for an element.

+3
source

it worked for me

 $(this).data('rel) 

and for html

 <div id="fruits" class="editme" data-rel="myfruits">apples</div> 
0
source

All Articles