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

Various functionality broken when target element not attached to DOM #389

Closed
elliterate opened this issue Dec 9, 2011 · 2 comments
Closed

Comments

@elliterate
Copy link

We're using Chosen in our application and using Jasmine to test the integration with the rest of our JavaScript. We're trying to keep as much of our JavaScript independent of the DOM as possible, which we ensure by testing it while detached, but we've run into a few cases where Chosen expects it to be in the DOM.

One such example is issue #358.

Another example is trying to click the "close" button on a multi-select choice. The lookup and subsequent click event bind rely on the button being in the DOM. To fix it, we had to modify line 596 of chosen.jquery.js (v0.9.5) from this:

link = $('#' + choice_id).find("a").first();

to this:

link = this.container.find('#' + choice_id).find("a").first();

It would seem that the general solution to these issues is to switch, whenever possible, from this:

$('...')

to this:

this.container.find('...')
@archaeron
Copy link

+1 this would be great. It' would be great if I could create the whole chosen element and attach it then to the DOM

@pfiller
Copy link
Contributor

pfiller commented Apr 24, 2013

#1151 resolves this as far as I can tell. Please pull the latest Chosen and check it out.

@pfiller pfiller closed this as completed Apr 24, 2013
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

3 participants