Я использую плагин Ajaxy jQuery: http://balupton.com/sandbox/jquery-ajaxy/
при посещении http://www.example.com/#/foo/ содержимое foo не отображается. вместо этого отображается содержимое моего index.php в корне.
вот как я инициализирую ajaxy:
var $body = $(document.body),
$menu = $('#wrapper'),
$content = $('#wrapper')
$.Ajaxy.configure({
'Controllers': {
'_generic': {
request: function(){
// Loading
$body.addClass('loading');
// Done
return true;
},
response: function(){
// Prepare
var Ajaxy = $.Ajaxy; var data = this.State.Response.data; var state = this.state||'unknown';
// Title
var title = data.title||false; // if we have a title in the response JSON
if ( !title && this.state||false ) title = 'jQuery Ajaxy - '+this.state; // if not use the state as the title
if ( title ) document.title = title; // if we have a new title use it
// Loaded
$body.removeClass('loading');
// Return true
return true;
},
error: function(){
// Prepare
var Ajaxy = $.Ajaxy; var data = this.State.Error.data||this.State.Response.data; var state = this.state||'unknown';
// Error
var error = data.error||data.responseText||'Unknown Error.';
var error_message = data.content||error;
// Log what is happening
window.console.error('$.Ajaxy.Controllers._generic.error', [this, arguments], error_message);
// Loaded
$body.removeClass('loading');
// Done
return true;
}
},
'page': {
classname: 'ajaxy-page',
matches: /^\/pages\/?/,
data: {ajaxy : true},
request: function(){
// Prepare
var Ajaxy = $.Ajaxy;
console.log(this);
// Adjust Menu
$menu.find('.active').removeClass('active');
// Hide Content
$content.stop(true,true).fadeOut(400);
console.log(arguments)
// Return true
return true;
},
response: function(){
// Prepare
var Ajaxy = $.Ajaxy; var data = this.State.Response.data; var state = this.state; var State = this.State;
// Adjust Menu
$menu.children(':has(a[href*="'+State.raw.state+'"])').addClass('active').siblings('.active').removeClass('active');
// Show Content
var Action = this;
console.log(data);
$content.html(data.content).fadeIn(400,function(){
Action.documentReady($content);
});
// Return true
return true;
}
}
},
root_url: url + '/',
relative_url: url + '/',
redirect: true
});
заранее спасибо
Lukas