JQuery Editable ID

I am new to jQuery and I am trying to use editable . I want to use the div tag identifier, since the records are taken from the database, and I need the identifier of each of them so that when I save the information, I can refer to it. How can I wear an identification number? This is my code:

<script language="javascript" type="text/javascript">
$(document).ready(
     function()
     {
          $('div.EditName').editable({
               type:'text',
               id : 'elementid',
           submit:'save',
       cancel:'cancel',
       onSubmit:SaveName
    })
     function SaveName(content,elementid)
     {
          alert(content.current);
          alert(elementid);
     }    
});

HTML code:

<div style="width:80%" class="EditName" id="Name7268">David Price</div>

At this point, I just want to display a warning containing the changed david price and div tag id number.

+3
source share
2 answers

the editable onSubmitcallback takes the following form (although the exception of arguments, like you, really):

function foo(content) { }

this jQuery, DOM node; ID .

id. .

, .


function SaveName(content) {
   alert(content.current);
   alert(this.attr('id'));
}

$(function() { // handy shortcut
   $('div.EditName').editable({
      type:    'text',
      submit:  'save',
      cancel:  'cancel',
      onSubmit: SaveName
   }); // you'd missed out this semicolon
});
+3
0

All Articles