jquery-editable-select
jquery-editable-select copied to clipboard
can't get the choosed option's value
i find sometimes i can't get the value of the option that have choosed( i use this way : $("ul").find("li[class$=selected]")[0].value).After i choosed the option, the li tag that i choosed sometimes won't add the "selected" class
@Zhao233 Have you solved it?
i think you are chinese,so,i anwser you with chinese,if you can't read it,please give me a reply。 我把那个js文件里的EditableSelectUtility.prototype.initializeList这个方法换掉了,就是换了它选中时候的class 换成了这个: EditableSelectUtility.prototype.initializeList = function () { var that = this; that.es.$list .on('mousemove', 'li:not([disabled])', function () {
that.es.$list.find('.focused').removeClass('focused');
$(this).addClass('focused');
})
.on('mousedown', 'li', function (e) {
if ($(this).is('[disabled]')) e.preventDefault();
else that.es.select($(this));
})
.on('mouseup', function () {
//that.es.$list.find('li.selected').removeClass('selected');
});
};
然后再把这个组件的css文件加一个class: .foucsed{ background: #dcedff; } 然后就好了,很迷
@Zhao233 嗯,你这样也可以。可以不用修改为.foucsed ,直接注释掉 mouseup事件就可以了。然后select通过.selected去取值选中的项就行了。 具体原因是因为 mouseup 的 bug (会偶尔丢失该事件,可以用 mouseleave来替代mouseup事件 )。不明白作者此处为什么要调用mouseup事件取消selected选择。
贼奇怪,,,,,我都是临时去写前端的,我都看不大懂他的库文件2333
English please
English please
A friend told me that you could remove the mouseup function,or replase it by mouseleave function in the jquery-editable-select.js (search this : EditableSelectUtility.prototype.initializeList = function () ) . Sometimes the mouseup function may uncaught by system
@Zhao233 嗯,你这样也可以。可以不用修改为.foucsed ,直接注释掉 mouseup事件就可以了。然后select通过.selected去取值选中的项就行了。 具体原因是因为 mouseup 的 bug (会偶尔丢失该事件,可以用 mouseleave来替代mouseup事件 )。不明白作者此处为什么要调用mouseup事件取消selected选择。
他的目的仅仅是添加和删除'selected' class样式,在li中其实并没真正记录选择项,因为选项值已经被赋到input textbox里了。
This will help you.
$(document).ready(function () {
$('#Category')
.editableSelect({
onSelect: function (element) {
$('#Category').attr("name",'Category');
$('#Category').attr("value",element[0].innerHTML);
}
})
});
Hi, I'm facing the same issue!! can anybody help please.
Hi, I'm facing the same issue!! can anybody help please.
Try my reply it worked for me