Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Popup fails to open when built on its own #5742

@gabrielschulhof

Description

@gabrielschulhof

Steps to reproduce:

  1. grunt js:compile --modules=widgets/popup
  2. Create a page that contains the resulting code.
  3. Attempt to open the popup - for example, from the console with $( "#thePopup" ).popup( "open" );

At this point, the popup fails to appear on the screen. The reason:

The popup attaches to "beforenavigate", and completes its opening sequence in response to the event.

Unfortunately, when build without init, the library does not call _registerInternalEvents(), which would cause a "navigate" binding to be added which, in turn, would cause the navigate special event's setup function to be called.

Popup uses "beforenavigate" before it attaches to navigate. "beforenavigate" is emitted by the navigate event code in addition to the navigate event. However, since it first attaches to "beforenavigate" and only then to "navigate", it never attaches to "navigate", meaning that, unless init runs as part of library load, the "navigate" event will not be initialized, and thus the popup will never receive the "beforenavigate" event it needs to complete the opening sequence.

Possible solutions:

  1. Popup depends on init. This is bad because there's no reason for this, other than to have init run _registerInternalEvents, which attaches a permanent navigate handler, causing the event to become initialized.
  2. $.mobile.document.one( "navigate", $.noop ); before attaching to beforenavigate. This is not an elegant solution.
  3. Initialize the "navigate" event even if somebody attaches to "beforenavigate" and not "navigate". I'm not sure how to accomplish this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions