jEditable: Display Option Text (and not Value) after submit

Alex picture Alex · Jul 3, 2011 · Viewed 7.5k times · Source

I'm using jEditable on a Select list. It works beautifully, except for the following issue. jEditable displays in place whatever a server posts back after a submit. That works great for text boxes etc. where you can simply post the submitted value back from the server.

However, this makes no sense on select lists because the value posted is simply the Id of an option element. If I post that back, then my text changes to the Id instead of the friendly text that was there before.

How can I turn this behavior off? I don't want to have to fetch the text value using the submitted Id from from the DB again just to post it back for display purposes. There should be a way to retain the option text and then have jEditable put it back in the label after submission. Help?

Answer

Felice Pollano picture Felice Pollano · Oct 22, 2012

Just add a callback in the editable configuration object, with this:

callback: function (value, settings) { 
      $(this).html(settings.data[value]);
 }