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

opt.selected = true not reflected #324

Open
stdedos opened this issue Aug 26, 2019 · 0 comments
Open

opt.selected = true not reflected #324

stdedos opened this issue Aug 26, 2019 · 0 comments

Comments

@stdedos
Copy link

stdedos commented Aug 26, 2019

I am using the example code http://loudev.com/#Searchable almost verbatim.

I have:

function pre_select_options(select_element, pre_select_options) {
	// // v2: awesome, but not working. multi-select error?
	// $(`${TC_SELECT_ELEMENT} option`).prop("selected", function () {
	// 	return ~$.inArray(this.text, pre_select_options) ? 'selected' : false;
	// });

	$(`${TC_SELECT_ELEMENT} option`).prop("selected", function () {
		return ~$.inArray(this.text, pre_select_options) ? 'selected' : false;
	});
}
window.onload = function() {
	pre_select_options($(TC_SELECT_ELEMENT)[0], window.location.hash.slice(1).split(','));

	//example-init-code
}

and, even though the element on devtools says $0.selected = true, it is not shown on the second list. Only rendering the page with selected="selected" works.

I might be missing the obvious (as I have very limited js experience), but kindly help.

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

1 participant