Can i use jQuery pjax with backbone.js

Is it possible to use jquery-pjax with backbone.js?

From what I see, routing with backbone.js is done using hashes in the url, however jquery-pjax seems to eliminate the need for hases to change the state of the site / application.

+4
source share
2 answers

You need to enable push state for Backbone to lose hashes, if supported

Backbone.history.start({pushState: true});

Change To clarify, none of the libraries will force push to work in older browsers, which does not support it, they use fallback behavior. There are two ways to support older browsers: you use hashes as a Backbone, and this provides a more consistent experience. With pjax, you will have to load a URL that is not ideal within the framework of the baseline paradigm, resulting in the need to create several separate pages for each possible route that your base application will have.

-3
source

Technically, you can. Here is the beginning of the chapter .

A different question: if that makes sense. I mean backbone design

associates all of this with your existing API through a RESTful JSON interface

Facilitates it, but the usual steps:

  • Create model
  • Get an API that will retrieve JSON data
  • Skip model to view
  • Display view using template
  • Add html generated by view in DOM

With PJAX, you can skip all this because you will have the html from the PJAX answer.

0
source

Source: https://habr.com/ru/post/1387920/


All Articles