2017 © Pedro Peláez
 

yii2-extension yii2-mpjax

Multi pjax + backbone.js implementation

image

filsh/yii2-mpjax

Multi pjax + backbone.js implementation

  • Tuesday, July 7, 2015
  • by Filsh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-mpjax

Multi pjax + backbone.js implementation, (*1)

Installation

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)

Usage

$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!");
  }
});

The Versions

07/07 2015

dev-master

9999999-dev https://github.com/filsh/yii2-mpjax

Multi pjax + backbone.js implementation

  Sources   Download

MIT

The Requires

 

by Igor Maliy

extension yii