diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index 28f04e132e0..6a8bfa9d28f 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -8,13 +8,15 @@ $(document).ready(function() { discussion = res['Inline Discussion'] share = res['Select to Tweet'] return def.resolve() - }) + }); def.done( function(){ var content = $("#blog_content p"); - if(content.length && discussion) + if(content.length && discussion){ + $('#discussions_wrapper').empty(); new openerp.website.blog_discussion({'content' : content}); + } if (share) $("p").share(); - }) + }); $('.cover_footer').on('click',page_transist); $('a[href^="#blog_content"]').on('click', animate); @@ -39,20 +41,21 @@ $(document).ready(function() { function newpage() { $.ajax({ - url: newLocation, + url: newLocation, }).done(function(data) { - $('main').append($(data).find('main').html()); - $("html").stop().animate({ scrollTop: $("#wrap:last-child").offset().top }, 1000,function(e){ - $("#wrap:first").remove(); - $(document).scrollTop($("#wrap:last-child").offset().top); - //bind again it takes control from now on, until page relaod. - $(document).find('.cover_footer').on('click',page_transist); - $(document).find('a[href^="#blog_content"]').on('click', animate); - var content = $(document).find("#blog_content p"); - if (content && discussion) + $('main').append($(data).find('main').html()); + $("html").stop().animate({ scrollTop: $("#wrap:last-child").offset().top }, 1000,function(e){ + $("#wrap:first").remove(); + $(document).scrollTop($("#wrap:last-child").offset().top); + //bind again it takes control from now on, until page relaod. + $(document).find('.cover_footer').on('click',page_transist); + $(document).find('a[href^="#blog_content"]').on('click', animate); + var content = $(document).find("#blog_content p"); + if (content && discussion){ new openerp.website.blog_discussion({'content' : content}); - if (share) $("p").share(); - }); + } + if (share) $("p").share(); + }); if (newLocation != window.location) { history.pushState(null, null, newLocation); }