I am new to jQuery and I am trying to use editable. I want to use the id of the the div tag as the entries are taken from a database and I need the id of each so that when I save the info I can reference it. how can I carry the id 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 the alert containing the Edited david price and the id number of the div tag.
editable’s
onSubmitcallback takes the following form (though omitting the arguments, as you did, is valid):Within this function,
thisis a jQuery object representing the DOM node in question; you can obtain the ID from that.editable’s options do not include an
idfield. Take a look at the documentation.Also, you have a syntax error.