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

dialog themed incorrectly when re-created #2215

Closed
fcheslack opened this Issue Aug 4, 2011 · 6 comments

Comments

Projects
None yet
6 participants
@fcheslack
Contributor

fcheslack commented Aug 4, 2011

http://jsfiddle.net/fcheslack/2ufpQ/1/

Create does not enhance the header/content/footer if the page has been created and is subsequently edited. That code is hidden in an anonymous function that only listens to pagecreate. So if you open footwo dialog, close it and modify the header/content/footer (or just recreate them losing the jqm markup) you cannot recover them when you show it again. This can be fixed by adding another event that anonymous function listens to and enhancing with that, but it can't be 'create' as that breaks it. It also loses the injected close button for the dialog. I would submit a patch fixing these but I'm unclear what the desired structure of that patch would be (and I haven't dug into the problems with having that page.sections markup listen for create).

@stevenday

This comment has been minimized.

Show comment
Hide comment
@stevenday

stevenday Aug 16, 2012

Is there any update on this issue and whether it will make it into 1.2? I just ran into it using Backbone to render a whole page as a view and then not being able to redo the header/content enhancements, which is a bit of a killer.

I'm also happy to take a look at providing a patch, but it sounds as if there's some guidance needed on the best way to do it, care to elaborate on anything that makes it particularly tricky?

stevenday commented Aug 16, 2012

Is there any update on this issue and whether it will make it into 1.2? I just ran into it using Backbone to render a whole page as a view and then not being able to redo the header/content enhancements, which is a bit of a killer.

I'm also happy to take a look at providing a patch, but it sounds as if there's some guidance needed on the best way to do it, care to elaborate on anything that makes it particularly tricky?

@viksit

This comment has been minimized.

Show comment
Hide comment
@viksit

viksit Aug 18, 2012

Why not just use .trigger('pagecreate') to do everything?

viksit commented Aug 18, 2012

Why not just use .trigger('pagecreate') to do everything?

@stevenday

This comment has been minimized.

Show comment
Hide comment
@stevenday

stevenday Aug 18, 2012

Good question! That's what I am doing actually, and for me it works great, but I read here: #2703 that it can cause other issues, so I assumed it wasn't a full solution, and the existence of this open issue confirmed that. Is there any clarification anywhere as to what could be affected by pagecreate?

stevenday commented Aug 18, 2012

Good question! That's what I am doing actually, and for me it works great, but I read here: #2703 that it can cause other issues, so I assumed it wasn't a full solution, and the existence of this open issue confirmed that. Is there any clarification anywhere as to what could be affected by pagecreate?

@jaspermdegroot

This comment has been minimized.

Show comment
Hide comment
@jaspermdegroot

jaspermdegroot Sep 3, 2012

Member

@scottjehl

Do you think binding to both pagecreate and create here https://github.com/jquery/jquery-mobile/blob/master/js/widgets/page.sections.js#L21 will have negative side effects?

Member

jaspermdegroot commented Sep 3, 2012

@scottjehl

Do you think binding to both pagecreate and create here https://github.com/jquery/jquery-mobile/blob/master/js/widgets/page.sections.js#L21 will have negative side effects?

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Nov 22, 2012

Contributor

This is not so much about re-enhancing page sections as it is about re-enhancing a dialog. The correct sequence to do that in your example is this:

J("#footwo-dialog")
  .page( "destroy" )
  .dialog( "destroy" )
  .empty()
  .html(J("#template").html());

The important thing here is to destroy the page widget and the dialog widget that end up getting instantiated on the element.

Here's an update to your example: http://jsbin.com/uzaret/534/

Note that the example suffers from #5318 as well as incorrect themeing.

Of course, implementing _destroy() for page and dialog would help make the above code a little simpler. For example, we could chain the destruction of the dialog to that of the page, so you only have to destroy the dialog widget.

Contributor

gabrielschulhof commented Nov 22, 2012

This is not so much about re-enhancing page sections as it is about re-enhancing a dialog. The correct sequence to do that in your example is this:

J("#footwo-dialog")
  .page( "destroy" )
  .dialog( "destroy" )
  .empty()
  .html(J("#template").html());

The important thing here is to destroy the page widget and the dialog widget that end up getting instantiated on the element.

Here's an update to your example: http://jsbin.com/uzaret/534/

Note that the example suffers from #5318 as well as incorrect themeing.

Of course, implementing _destroy() for page and dialog would help make the above code a little simpler. For example, we could chain the destruction of the dialog to that of the page, so you only have to destroy the dialog widget.

@gabrielschulhof

This comment has been minimized.

Show comment
Hide comment
@gabrielschulhof

gabrielschulhof Nov 22, 2012

Contributor

I've changed the issue summary from "page.section enhancements can't be applied to new injected html".

Contributor

gabrielschulhof commented Nov 22, 2012

I've changed the issue summary from "page.section enhancements can't be applied to new injected html".

gabrielschulhof added a commit that referenced this issue Nov 23, 2012

Dialog: Attach pagebeforeshow handler using ._on(). Fixes #2215.
When a dialog widget is destroyed on an element, the pagebeforeshow handler must be removed, otherwise, if another dialog widget is instantiated on the same element later on, the handler from the previous instance will be left around and so the new instance will have the event handled twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment