Шаблон магистрали, работающий на MAMP, не может заставить маршрутизатор работать

В настоящее время я использую магистральный шаблон и запускаю его на локальном хосте своего сервера MAMP. не могу заставить роутер работать

require([
  // Global
  "app",

  // Libs
  "jquery",
  "backbone"
],

function(app, $, Backbone) {

  // Defining the application router, you can attach sub routers here.
  var Router = Backbone.Router.extend({
    routes: {
      "photo" : "getPhoto",
      "*other" : "index"
    },

    index: function() 
    {
        console.info('Index Function Working');
    },

    getPhoto: function()
    {
        console.log("You are trying to reach photo ");
    }

  });

  // Treat the jQuery ready function as the entry point to the application.
  // Inside this function, kick-off all initialization, everything up to this
  // point should be definitions.
  $(function() {
    // Define your master router on the application namespace and trigger all
    // navigation from this instance.
    app.router = new Router();
    console.info('Here');

    // Trigger the initial route and enable HTML5 History API support
    Backbone.history.start({ pushState: true });
  });

  // All navigation that is relative should be passed through the navigate
  // method, to be processed by the router. If the link has a `data-bypass`
  // attribute, bypass the delegation completely.
  $(document).on("click", "a:not([data-bypass])", function(evt) {
    // Get the anchor href and protocol
    var href = $(this).attr("href");
    var protocol = this.protocol + "//";
    // Ensure the protocol is not part of URL, meaning it's relative.
    if (href && href.slice(0, protocol.length) !== protocol &&
        href.indexOf("javascript:") !== 0) {
      // Stop the default event to ensure the link will not cause a page
      // refresh.
      evt.preventDefault();

      // `Backbone.history.navigate` is sufficient for all Routers and will
      // trigger the correct events. The Router's internal `navigate` method
      // calls this anyways.
      Backbone.history.navigate(href, true);
    }
  });

});

Он просто продолжает нажимать на индексную функцию.

Я поместил это в свой URL-адрес "http://localhost:8888/OutfitApp/#photo. *" и "http://localhost:8888/OutfitApp/photo"

Оба не работают.

Я удалил

"*other" : "index" 

и ничего не выходит в мою консоль.

Я в замешательстве, что я упускаю??


person mcclennon19    schedule 22.06.2012    source источник
comment
как это должно быть связано со стеком сервера (MAMP)?   -  person chiccodoro    schedule 22.06.2012


Ответы (1)


Из документов:

Если ваше приложение не обслуживается с корневого URL-адреса / вашего домена, обязательно сообщите Истории, где на самом деле находится корень, как вариант: Backbone.history.start({pushState: true, root: "/public/search/ "})

Может ли это быть проблема?

В вашем случае попробуйте:

Backbone.history.start({pushState: true, root: "/OutfitApp/"})
person codeape    schedule 22.06.2012