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

Dynamic Select empty when opening second time. #5935

Closed
AdoWebDesig opened this Issue Apr 25, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@AdoWebDesig

Hi,

When opening select(dromdown) for secod time, the list is empy. This happens only if the list does not fit on the screen:

http://jsfiddle.net/nzHxZ/1/

  1. Click on Go to
  2. open both dropdowns
  3. go back to home
  4. Do again step 1 to 3

You wil see that big dropdown is empty when opening second time.

@jaspermdegroot

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Apr 25, 2013

Member

@AdoWebDesig

Thank for reporting the issue. This is indeed a bug.

Member

jaspermdegroot commented Apr 25, 2013

@AdoWebDesig

Thank for reporting the issue. This is indeed a bug.

@jaspermdegroot

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Apr 25, 2013

Member

Cleaned up the test page (missing body tag, don't append a select to a ul, use latest code): http://jsbin.com/owasir/23/edit

Member

jaspermdegroot commented Apr 25, 2013

Cleaned up the test page (missing body tag, don't append a select to a ul, use latest code): http://jsbin.com/owasir/23/edit

@vstars

This comment has been minimized.

Show comment
Hide comment
@vstars

vstars Apr 26, 2013

I removed the old dialog page of select if it exits in the build function of widget. The select can be opened for second time.
http://jsbin.com/amuzad/1/edit/

vstars commented Apr 26, 2013

I removed the old dialog page of select if it exits in the build function of widget. The select can be opened for second time.
http://jsbin.com/amuzad/1/edit/

@AdoWebDesig

This comment has been minimized.

Show comment
Hide comment
@AdoWebDesig

AdoWebDesig Apr 26, 2013

Thx guys!

@uGoMobi,

One question. Do I always have to use pageinit when adding events like click ets?

Thx guys!

@uGoMobi,

One question. Do I always have to use pageinit when adding events like click ets?

@jaspermdegroot

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Apr 26, 2013

Member

@AdoWebDesig

I strongly recommend to always bind to pageinit, instead of $(handler) or $(document).ready(handler). There are situations where it doesn't make a difference, but better make a habit of it.

As @vstars pointed out, the problem here is indeed the selectmenu dialog page that remains in the DOM, only the list is removed from the dialog.

The dialog that is created gets the same ID as your select with the "-dialog" suffix. You create a new select with the same ID each time the button on the homepage is clicked. The framework doesn't create a new dialog a second time because there is already a dialog with that ID. If you don't give the select an ID, the dialog gets a random ID uuid-[random number]-dialog and the problem is gone: http://jsbin.com/owasir/28/edit

However, this way you can end up with many dialogs in the DOM which is not good. So a better workaround is to remove the dialog with custom code. See: http://jsbin.com/owasir/29/edit

Member

jaspermdegroot commented Apr 26, 2013

@AdoWebDesig

I strongly recommend to always bind to pageinit, instead of $(handler) or $(document).ready(handler). There are situations where it doesn't make a difference, but better make a habit of it.

As @vstars pointed out, the problem here is indeed the selectmenu dialog page that remains in the DOM, only the list is removed from the dialog.

The dialog that is created gets the same ID as your select with the "-dialog" suffix. You create a new select with the same ID each time the button on the homepage is clicked. The framework doesn't create a new dialog a second time because there is already a dialog with that ID. If you don't give the select an ID, the dialog gets a random ID uuid-[random number]-dialog and the problem is gone: http://jsbin.com/owasir/28/edit

However, this way you can end up with many dialogs in the DOM which is not good. So a better workaround is to remove the dialog with custom code. See: http://jsbin.com/owasir/29/edit

@AdoWebDesig

This comment has been minimized.

Show comment
Hide comment
@AdoWebDesig

AdoWebDesig Apr 26, 2013

Thank you very much.

Thank you very much.

gabrielschulhof added a commit that referenced this issue May 2, 2013

Custom select: Remove dialog upon _destroy. Fixes #5935 - Dynamic Sel…
…ect empty when opening second time.

(cherry picked from commit afabf5b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment