jquery-editable-select icon indicating copy to clipboard operation
jquery-editable-select copied to clipboard

can't get the choosed option's value

Open Zhao233 opened this issue 6 years ago • 10 comments

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 avatar Sep 03 '18 05:09 Zhao233

@Zhao233 Have you solved it?

NxGreen avatar Sep 30 '18 03:09 NxGreen

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 avatar Sep 30 '18 04:09 Zhao233

@Zhao233 嗯,你这样也可以。可以不用修改为.foucsed ,直接注释掉 mouseup事件就可以了。然后select通过.selected去取值选中的项就行了。 具体原因是因为 mouseup 的 bug (会偶尔丢失该事件,可以用 mouseleave来替代mouseup事件 )。不明白作者此处为什么要调用mouseup事件取消selected选择。

NxGreen avatar Sep 30 '18 07:09 NxGreen

贼奇怪,,,,,我都是临时去写前端的,我都看不大懂他的库文件2333

Zhao233 avatar Sep 30 '18 12:09 Zhao233

English please

huuthang1993 avatar Oct 08 '18 04:10 huuthang1993

      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 avatar Oct 08 '18 04:10 Zhao233

@Zhao233 嗯,你这样也可以。可以不用修改为.foucsed ,直接注释掉 mouseup事件就可以了。然后select通过.selected去取值选中的项就行了。 具体原因是因为 mouseup 的 bug (会偶尔丢失该事件,可以用 mouseleave来替代mouseup事件 )。不明白作者此处为什么要调用mouseup事件取消selected选择。

他的目的仅仅是添加和删除'selected' class样式,在li中其实并没真正记录选择项,因为选项值已经被赋到input textbox里了。

wannadream avatar Oct 25 '18 00:10 wannadream

This will help you.

      $(document).ready(function () {
            $('#Category')
                .editableSelect({
                    onSelect: function (element) {
                        $('#Category').attr("name",'Category');
                        $('#Category').attr("value",element[0].innerHTML);
                    }
                })
                
        });

VivekMoyal28 avatar Jun 24 '20 14:06 VivekMoyal28

Hi, I'm facing the same issue!! can anybody help please.

thebatmanreturns avatar Jul 04 '20 06:07 thebatmanreturns

Hi, I'm facing the same issue!! can anybody help please.

Try my reply it worked for me

VivekMoyal28 avatar Jul 05 '20 04:07 VivekMoyal28