Fixed navigating between posts
This commit is contained in:
parent
5dc85b7dee
commit
0d8ae5334d
1 changed files with 12 additions and 8 deletions
|
@ -29,7 +29,6 @@ App.Presenters.PostPresenter = function(
|
||||||
var postThumbnail;
|
var postThumbnail;
|
||||||
|
|
||||||
function init(args, loaded) {
|
function init(args, loaded) {
|
||||||
postNameOrId = args.postNameOrId;
|
|
||||||
topNavigationPresenter.select('posts');
|
topNavigationPresenter.select('posts');
|
||||||
|
|
||||||
privileges.canDeletePosts = auth.hasPrivilege(auth.privileges.deletePosts);
|
privileges.canDeletePosts = auth.hasPrivilege(auth.privileges.deletePosts);
|
||||||
|
@ -44,8 +43,7 @@ App.Presenters.PostPresenter = function(
|
||||||
promise.waitAll(
|
promise.waitAll(
|
||||||
util.promiseTemplate('post'),
|
util.promiseTemplate('post'),
|
||||||
util.promiseTemplate('post-edit'),
|
util.promiseTemplate('post-edit'),
|
||||||
util.promiseTemplate('post-content'),
|
util.promiseTemplate('post-content'))
|
||||||
api.get('/posts/' + postNameOrId))
|
|
||||||
.then(function(
|
.then(function(
|
||||||
postTemplateHtml,
|
postTemplateHtml,
|
||||||
postEditTemplateHtml,
|
postEditTemplateHtml,
|
||||||
|
@ -55,15 +53,20 @@ App.Presenters.PostPresenter = function(
|
||||||
postEditTemplate = _.template(postEditTemplateHtml);
|
postEditTemplate = _.template(postEditTemplateHtml);
|
||||||
postContentTemplate = _.template(postContentTemplateHtml);
|
postContentTemplate = _.template(postContentTemplateHtml);
|
||||||
|
|
||||||
|
reinit(args, loaded);
|
||||||
|
}).fail(showGenericError);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reinit(args, loaded) {
|
||||||
|
postNameOrId = args.postNameOrId;
|
||||||
|
|
||||||
|
promise.wait(api.get('/posts/' + postNameOrId))
|
||||||
|
.then(function(response) {
|
||||||
post = response.json;
|
post = response.json;
|
||||||
topNavigationPresenter.changeTitle('@' + post.id);
|
topNavigationPresenter.changeTitle('@' + post.id);
|
||||||
render();
|
render();
|
||||||
loaded();
|
loaded();
|
||||||
|
}).fail(showGenericError);
|
||||||
}).fail(function(response) {
|
|
||||||
$el.empty();
|
|
||||||
showGenericError(response);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
|
@ -232,6 +235,7 @@ App.Presenters.PostPresenter = function(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
|
reinit: reinit,
|
||||||
render: render
|
render: render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue