Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get the choosed option's value #63

Open
Zhao233 opened this issue Sep 3, 2018 · 10 comments
Open

can't get the choosed option's value #63

Zhao233 opened this issue Sep 3, 2018 · 10 comments

Comments

@Zhao233
Copy link

Zhao233 commented Sep 3, 2018

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

@NxGreen
Copy link

NxGreen commented Sep 30, 2018

@Zhao233 Have you solved it?

@Zhao233
Copy link
Author

Zhao233 commented Sep 30, 2018

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;
}
然后就好了,很迷

@NxGreen
Copy link

NxGreen commented Sep 30, 2018

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

@Zhao233
Copy link
Author

Zhao233 commented Sep 30, 2018

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

@huuthang1993
Copy link

English please

@Zhao233
Copy link
Author

Zhao233 commented Oct 8, 2018

      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

@wannadream
Copy link
Collaborator

wannadream commented Oct 25, 2018

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

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

@VivekMoyal28
Copy link

VivekMoyal28 commented Jun 24, 2020

This will help you.

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

@thebatmanreturns
Copy link

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

@VivekMoyal28
Copy link

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

Try my reply it worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants