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

resetActivePageHeight() isn't called on pageshow #7386

Closed
DzenisevichK opened this issue May 9, 2014 · 6 comments
Closed

resetActivePageHeight() isn't called on pageshow #7386

DzenisevichK opened this issue May 9, 2014 · 6 comments
Assignees
Milestone

Comments

@DzenisevichK
Copy link

Related to commit:
65ad2f9

loadDeferred is never resolved on Chrome (34.0.1847.131 m) on Windows 7 SP1 x64:

    $.mobile.window.load( function() {

        // Resolve and null the deferred
        loadDeferred.resolve();
        loadDeferred = null;
    });

so resetActivePageHeight is never called on pageshow:

        $.mobile.document.bind( "pageshow", function() {

            // We need to wait for window.load to make sure that styles have already been rendered,
            // otherwise heights of external toolbars will have the wrong value
            if ( loadDeferred ) {
                loadDeferred.done( $.mobile.resetActivePageHeight );
            } else {
                $.mobile.resetActivePageHeight();
            }
        });
@DzenisevichK DzenisevichK changed the title resetActivePageHeight() doesn't called on pageshow resetActivePageHeight() isn't called on pageshow May 9, 2014
@DzenisevichK
Copy link
Author

I found that there are no problems on http://view.jquerymobile.com/master/demos/pages-multi-page/ standard example.

In my case I don't use autoInitializePage and trigger initializePage when requirejs finish loading.

@DzenisevichK
Copy link
Author

A test page to reproduce the problem:
http://view.jquerymobile.com/master/demos/backbone-requirejs/backbone-require.html

Here $.mobile.resetActivePageHeight is never called on pageshow

@gabrielschulhof
Copy link

OK, I think I understand the problem. If you do not initialize the page, navreadyDeferred isn't resolved, which means loadDeferred isn't attached to load until after load() has already fired. I guess it would be better to check document.readyState before attaching to load() to make sure it's not yet "complete".

@DzenisevichK
Copy link
Author

@gabrielschulhof

What do you think also about introducing new event: pageresize and trigger it from resetActivePageHeight after setting min-height?

This even may be used to expand a widget height (for example textarea,ui-textinput) to fill all not used space in .ui-content...

This idea even better then autogrow option and universal (independent from widget type - may be applied to any tag).

@gabrielschulhof
Copy link

@DzenisevichK this is not a bad idea. However, this involves a bit of re-thinking, so I have framed this as a feature request.

@DzenisevichK
Copy link
Author

I use this code for implementing .ui-fullheight behaviour:

$(window.document).on("pageinit", function (event) {
    var $page = $(event.target),
        $fullHeight = $page.find(".ui-fullheight");
    if (!$fullHeight.length) {
        // Improve performance by skipping pages from processing
        // which initially don't have fullheight widgets
        return;
    }
    $page.on("pageresize updatelayout", function () {
        $fullHeight
            // Only the first visible fullheight widget may be expanded
            .filter(":visible:first")
            .each(function () {
                var $element = $(this),
                    initHeight = $element.jqmData("init-height");
                if (!initHeight) {
                    // Save initial height
                    initHeight = $element.height();
                    $element.jqmData("init-height", initHeight);
                }
                $element
                    // Reset height to calculate correct extra space in content
                    .height(0)
                    .height(
                        Math.max(
                            initHeight,
                            // Calculate extra space
                            $page.outerHeight() -
                                $page.find(".ui-header").outerHeight() -
                                $page.find(".ui-content").outerHeight()
                        )
                    );
            });
    });
});

gabrielschulhof pushed a commit that referenced this issue May 23, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants