Search code examples
x-editable

X-Editible, setValue doesn't seem to work


I'm trying to work out how to update the value passed back from a script, with X-Editible. The HTML is:

<h2 id="store-editible-url" data-type="text" data-pk="1" data-name="store_url">test value</h2>

And the script:

$(document).ready(function(){
    $('#store-editible-url').editable( {
        url: 'http://www.example.com/cgi-bin/art/my-store.cgi',
        onblur: "submit",
        placeholder: "Click to set a custom URL",
        emptytext: "Click to set a custom URL",
        params: { action: "update_store_url" },
        success: function(response, newValue) {
              $('#store-editible-url').editable('setValue',"foo",true);
        }
    });
});

Here is a fiddle, although it doesn't work as such (due to the fact the URL isn't a valid one).

The idea is that the server does some sanitising, and then passes the value back to the browser. Howeve4r, for simplicity sake my demo code just does:

$('#store-editible-url').editable('setValue',"foo",true);

I don't get an error, but it's not updated. Here is the fiddle:

http://jsfiddle.net/nrtrdo39/1/setValue

Any ideas?


Solution

  • I'm no expert on x-editable, but as far as I understand, you will need to just do $('#store-editible-url').editable("foo",true); on order to set the value of property "foo" or for data- type options, $('#store-editible-url').editable('option','pk',1);