2
현재 백본 상용구를 사용 중이며 MAMP 서버 localhost에서 실행 중입니다. 라우터를 사용할 수없는 것 같습니다.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"
을 제거하고 아무것도 내 콘솔에 나오는 없습니다.
내가 무엇을 놓치고 있는지 혼란 스럽습니까 ?? docs에서
방법이이 서버 스택 (MAMP)에 관련되어야 하는가? – chiccodoro