admin管理员组

文章数量:1327849

I need to use inline edit in my application. For this purpose I am using the Jeditable plugin for jQuery.

I want to trigger editable mode for an element only when I click on it. This is my code which doesn't work:

var tet = "";
$(".edit-client").click(function(event) {
    tet = "#"+event.target.id;
    //alert(tet);
});

$(tet).editable("/bestcredit/admin.php/request/editClient", {
    submitdata : function (value,settings){
                    return {"Client[id]":'.$model->client->id.' };
                },

    //indicator : "Saving...",
    //tooltip   : "Click to edit...",
    submit   : "OK",
    name : "Client["+tet.substr("1")+"]"
    //alert(1);
 }); 

How can I add this functionality?

I need to use inline edit in my application. For this purpose I am using the Jeditable plugin for jQuery.

I want to trigger editable mode for an element only when I click on it. This is my code which doesn't work:

var tet = "";
$(".edit-client").click(function(event) {
    tet = "#"+event.target.id;
    //alert(tet);
});

$(tet).editable("/bestcredit/admin.php/request/editClient", {
    submitdata : function (value,settings){
                    return {"Client[id]":'.$model->client->id.' };
                },

    //indicator : "Saving...",
    //tooltip   : "Click to edit...",
    submit   : "OK",
    name : "Client["+tet.substr("1")+"]"
    //alert(1);
 }); 

How can I add this functionality?

Share Improve this question edited Jun 6, 2019 at 6:58 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 14, 2012 at 12:22 nyanevnyanev 11.5k7 gold badges50 silver badges77 bronze badges 1
  • Possible duplicate of Jeditable - Activate edit of X by clicking on Y – CodeBrauer Commented Oct 5, 2016 at 10:08
Add a ment  | 

1 Answer 1

Reset to default 10

There are many ways to do it and it all depends on your HTML, but for example if you have following HTML:

<div class="edit" id="unique_id">Editable text</div> 
<a href="#" class="edit_trigger">Edit me!!</a>

Then you can use following JavaScript:

/* Bind Jeditable instances to "edit" event. */
$(".edit").editable("http://www.example./save.php", {
    event     : "edit"
});
/* Find and trigger "edit" event on correct Jeditable instance. */
$(".edit_trigger").bind("click", function() {
    $(this).prev().trigger("edit");
});

本文标签: javascriptjQuery jeditable trigger on clickStack Overflow