Skip to content

Can't find container.contents with "most common use of pjax" rise reload page any time #702

Open
@bscheshirwork

Description

@bscheshirwork
The simplest and most common use of pjax looks like this:

$(document).pjax('a', '#pjax-container')

so... the option.fragment not definite =>

jquery-pjax/jquery.pjax.js

Lines 686 to 705 in 153262e

if (options.fragment) {
var $fragment = $body
// If they specified a fragment, look for it in the response
// and pull it out.
if (options.fragment !== 'body') {
$fragment = findAll($fragment, options.fragment).first()
}
if ($fragment.length) {
obj.contents = options.fragment === 'body' ? $fragment : $fragment.contents()
// If there's no title, look for data-title and title attributes
// on the fragment
if (!obj.title)
obj.title = $fragment.attr('title') || $fragment.data('title')
}
} else if (!fullDocument) {
obj.contents = $body
}

in fullDocument case the obj.contents not set

jquery-pjax/jquery.pjax.js

Lines 276 to 280 in 153262e

// If the new response is missing a body, hard load the page
if (!container.contents) {
locationReplace(container.url)
return
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions