dev-master
9999999-dev https://github.com/filsh/yii2-mpjaxMulti pjax + backbone.js implementation
MIT
The Requires
- yiisoft/yii2 *
- bower-asset/backbone *
by Igor Maliy
extension yii
Wallogit.com
2017 © Pedro Peláez
Multi pjax + backbone.js implementation
Multi pjax + backbone.js implementation, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist filsh/yii2-mpjax "*", (*4)
or add, (*5)
"filsh/yii2-mpjax": "*", (*6)
to the require section of your composer.json, (*7)
$this->beginMpjax('header');
echo '
header
';
$this->endMpjax();
$this->beginMpjax('body');
echo '
body
';
$this->endMpjax();
Backbone.Mpjax = {
Router: Backbone.Router.extend({
navigate: function (fragment, options) {
this.trigger('mpjax:start', fragment);
Backbone.Router.prototype.navigate.apply(this, [fragment, options]);
var self = this;
$.ajax({
url: fragment,
beforeSend: function (xhr) {
xhr.setRequestHeader('X-PJAX', 'true');
xhr.setRequestHeader('X-PJAX-Container-0', 'header');
xhr.setRequestHeader('X-PJAX-Container-1', 'body');
},
success: function (data) {
// Object { header="<div>header</div>", body="<div>body</div>"}
self.trigger('mpjax:success');
},
error: function () {
self.trigger('mpjax:error');
}
});
}
})
};
var Router = Backbone.Mpjax.Router.extend({
routes: {
"test": "test"
},
test: function(){
console.log("Test!");
}
});
Multi pjax + backbone.js implementation
MIT
extension yii