jEditable:提交后显示选项文本(而非值) [英] jEditable: Display Option Text (and not Value) after submit

查看:165
本文介绍了jEditable:提交后显示选项文本(而非值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在选择"列表上使用jEditable.除了以下问题外,它的工作原理非常漂亮.提交后,无论服务器回发什么,jEditable都会在适当位置显示.这对于文本框等非常有用.在这里,您可以简单地将提交的值从服务器发回.

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.

但是,这在选择列表上没有意义,因为发布的值只是选项元素的ID.如果我将其发布回去,那么我的文本将更改为ID,而不是之前的友好文本.

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.

如何关闭此行为?我不想再次使用从数据库提交的ID来获取文本值,而只是将其回发以用于显示.应该有一种方法可以保留选项文本,然后在提交后让jEditable将其重新放置在标签中.帮助吗?

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?

推荐答案

只需在可编辑配置对象中添加一个回调,即可:

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

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

这篇关于jEditable:提交后显示选项文本(而非值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆