3

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
nyanev
  • 11,299
  • 6
  • 47
  • 76
  • Possible duplicate of [Jeditable - Activate edit of X by clicking on Y](http://stackoverflow.com/questions/366595/jeditable-activate-edit-of-x-by-clicking-on-y) – CodeBrauer Oct 05 '16 at 10:08

1 Answers1

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.com/save.php", {
    event     : "edit"
});
/* Find and trigger "edit" event on correct Jeditable instance. */
$(".edit_trigger").bind("click", function() {
    $(this).prev().trigger("edit");
});
Mika Tuupola
  • 19,877
  • 5
  • 42
  • 49
  • 2
    I'm not sure if this answers the original question - I'm not actually sure I understand the original question - but this answers *my* question, so +1. – pjmorse Nov 08 '12 at 18:49