[英]jEditable & Chosen combined
I am using the jQuery plugins jEditable & Chosen to create an inline edit with the following script: 我正在使用jQuery插件jEditable&Chosen通过以下脚本创建内联编辑:
$('.inline_edit_menu').editable('ajax.php', { // http://polyetilen.lt/en/jquery-jeditable-and-chosen-hybrid
data: "{'5':'Complete - No further action','4':'Unsatisfied - additional steps required','3':'Unsatisfactory - Re-Evaluate','2':'Test','1':'Pending','0':'Not Applicable'}",
indicator: 'Saving...',
tooltip: 'Click to edit...',
style: "inherit",
onblur: "ignore",
type : 'select',
submit : 'OK',
submitdata: function (value, settings) {
//do stuff
}
}).on('click', function(){
$(this).find('select').chosen();
}).on('click', function(){
$('select').trigger('chosen:open');
});
This works fantastic, as seen in this fiddle, with one caveat: on selecting a menu item, it doesn't submit it. 就像在小提琴中看到的那样,这非常棒,但有一个警告:选择菜单项时,它不会提交。 I want the click event to submit the value selected, without having to click "OK".
我希望单击事件提交选定的值,而不必单击“确定”。 - https://jsfiddle.net/t24ph41t/2/
-https://jsfiddle.net/t24ph41t/2/
This would be easily solved by changing jEditable's onblur
property to select
. 通过将jEditable的
onblur
属性更改为select
可以轻松解决此问题。 However, the problem with the current script is the initial click event automatically opens & closes the Chosen menu, as seen in this fiddle: - https://jsfiddle.net/t24ph41t/3/ 但是,当前脚本的问题是初始点击事件会自动打开和关闭“选择”菜单,如该小提琴所示:-https: //jsfiddle.net/t24ph41t/3/
I'm looking for a combination of both: how can I select an inline element using the chosen plugin, edit it and on choosing, submit the value as if this was simply a jEditable element? 我正在寻找两者的组合:如何使用所选插件选择内联元素,对其进行编辑,然后选择就象只是jEditable元素一样提交值?
I was able to get this functionality by adding the following script: 我可以通过添加以下脚本来获得此功能:
$(document).on('change', '.inline_edit_menu select', function () {
$(this).trigger("submit");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.