-
Notifications
You must be signed in to change notification settings - Fork 300
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
selectBoxItfied select element doesn't update the widget to reflect the newly selected value when programmatically changing the value of the select element using jQuery #28
Comments
I just released SelectBoxIt v1.7.0, which includes multiple bug fixes (including yours). Everything should work for you now, but let me know if you have any other issues. Thanks! |
Thanks for such a quick update ;) However, I don't think this is works too well, though, as I spotted at least two rough edges.
diff --git a/src/javascripts/jquery.selectBoxIt.js b/src/javascripts/jquery.selectBoxIt.js index c8a3eb9..43e07e6 100644 --- a/src/javascripts/jquery.selectBoxIt.js +++ b/src/javascripts/jquery.selectBoxIt.js @@ -1098,7 +1098,8 @@ else { // Sets the new dropdown list text to the value of the original dropdown list - self.divText.text(self.originalElem.value).attr("data-val", self.originalElem.value); + var text = $(self.originalElem).children("option:selected").text(); + self.divText.text(text.length > 0 ? text : self.originalElem.value).attr("data-val", self.originalEle } |
I think I came up with a better solution. Below is my new code for the else condition (If a user sets the dropdown value programatically):
I have updated the code and the SelectBoxIt website, so let me know if you still have issues. |
Yes now it seems to work as expected. Thank you! |
Consider the following scenario.
Load http://gregfranko.com/jquery.selectBoxIt.js/ using Firefox with Firebug installed
Open the Firebug console
Run the following JavaScript snippet in the console
$('select').first().val('a Stateful UI Widget').change()
The selected value of the first native select element on the page will change. Now let's try the same for the corresponding selectBoxItfied select:
$(":selectBox-selectBoxIt").first().val('a Stateful UI Widget').change()
The result is that the selection is not reflected in the selectBoxIt element. It should behave like the native select element and change to the new value.
The text was updated successfully, but these errors were encountered: