Skip to content

Commit

Permalink
Fixed yii.js to follow jquery-pjax API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Oct 6, 2017
1 parent fa1ca13 commit 7e681b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 7 additions & 1 deletion framework/assets/yii.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ window.yii = (function ($) {
pjaxOptions = {};

if (usePjax) {
pjaxContainer = $e.data('pjax-container') || $e.closest('[data-pjax-container]');
debugger;
pjaxContainer = $e.data('pjax-container');
if (pjaxContainer === undefined || !pjaxContainer.length) {
pjaxContainer = $e.closest('[data-pjax-container]').attr('id')
? ('#' + $e.closest('[data-pjax-container]').attr('id'))
: '';
}
if (!pjaxContainer.length) {
pjaxContainer = 'body';
}
Expand Down
10 changes: 2 additions & 8 deletions tests/js/tests/yii.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,7 @@ describe('yii', function () {
var pjaxOptions = pjaxClickStub.getCall(0).args[1];

// container needs to be checked separately

if (typeof pjaxOptions.container === 'string') {
assert.equal(pjaxOptions.container, pjaxContainerId || 'body');
} else {
assert.instanceOf(pjaxOptions.container, $);
assert.equal(pjaxOptions.container.attr('id'), pjaxContainerId || 'body');
}
assert.equal(pjaxOptions.container, pjaxContainerId || 'body');
delete pjaxOptions.container;

assert.deepEqual(pjaxOptions, {
Expand Down Expand Up @@ -500,7 +494,7 @@ describe('yii', function () {
'link, data-pjax, outside a container': [
'.link-pjax-outside-container', '#pjax-separate-container'
],
'link href, data-pjax, inside a container': ['.link-pjax-inside-container', 'pjax-container-2']
'link href, data-pjax, inside a container': ['.link-pjax-inside-container', '#pjax-container-2']
}, function (elementSelector, expectedPjaxContainerId) {
it(pageLoadWithPjaxMessage, function () {
var event = $.Event('click');
Expand Down

0 comments on commit 7e681b4

Please sign in to comment.