2013-01-25 1 views
0

내 백본 응용 프로그램에서 나는 addthis 버튼을 사용했습니다. 내 문제는 내가 하나의 경로로 응용 프로그램을 탐색하고 주요 경로로 돌아갈 때 버튼 (fb, twitter, share)이 사라 졌다는 것입니다. 그러나 페이지를 새로 고침하면 버튼이 표시되고 도움이됩니다. 코드는 아래와 같습니다추가 버튼이 사라졌습니다.

사전에

감사합니다 ... 내 템플릿 파일의

var mainProfileView = Backbone.View.extend({ 
    el:"#inner", 
    template: _.template($('#main-profile-tmpl').html()), 
    initialize: function(){ 
     _.bindAll(this, "render"); 
     this.render(); 
    }, 
    events:{ 
     'click .profile-details' : 'detailedProfile', 
     'click .credibility' : 'credibility', 
     'click #moreReviews': 'moreReview', 
     'click #moreReferences' : 'moreReferences' 
    }, 
    detailedProfile:function(){ 
     router.navigate('/detailedProfile',true); 
    }, 
    credibility : function() { 
     router.navigate('/credit',true); 
    }, 
    moreReview : function() { 
     router.navigate('/moreReviews',true); 
    }, 
    moreReferences : function() { 
     router.navigate('/moreReferences',true); 
    }, 
    render: function(){ 
     this.$el.html(this.template()); 
    } 
}); 

var creditView = Backbone.View.extend({ 
    el:"#inner", 
    template: _.template($('#credit-tmpl').html()), 
    initialize: function(){ 
     _.bindAll(this, "render"); 
     this.render(); 
    }, 
    render: function(){ 
     this.$el.html(this.template()); 
    } 
}); 

ProfileRouter = Backbone.Router.extend({ 
    initialize : function() { 

    }, 
    routes : { 
     '' : 'profile', 
     'detailedProfile' : 'detailedProfile', 
     'credit' : 'credit' 
    }, 
    profile : function() { 
     $('#img-loader').fadeIn(); 
     currentView = new mainProfileView(); 
     currentView.render(); 
    }, 
    credit : function() { 
     $('#img-loader').fadeIn(); 
     if (currentView){ 
      currentView.undelegateEvents(); 
      delete currentView; 
     } 

     currentView = new creditView(); 
     currentView.render(); 
    }, 
    moreReviews : function() { 
     $('#img-loader').fadeIn(); 
     if (currentView){ 
      currentView.undelegateEvents(); 
      delete currentView; 
     } 

     review = new Reviews; 
     review.fetch({ 
      data: { 
        profile_id : profile_id 
      }, 
      type : 'POST', 
      success: function(model,response,options) { 
       currentView = new moreReviewView({reviews : model}); 
       currentView.render(); 
      }, 
      error: function(model,response,options) { 
       //console.log(response.responseText); 
      } 

     }); 
    } 
}); 

한 부분 당신은 addthis_widget 스크립트 매를 호출 할뿐만 아니라 필요

<script type="text/template" id="main-profile-tmpl"> 
....... 
      <div class="block with-padding service-area-container"> 
       <h5>Social</h5> 
       <div class="addthis_toolbox addthis_default_style "> 
        <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> 
        <a class="addthis_button_tweet"></a> 
        <a class="addthis_button_pinterest_pinit"></a> 
        <a class="addthis_counter addthis_pill_style"></a> 
       </div> 
      </div> 
    </script> 
+0

코드는 – doniyor

+0

이 문제를 해결하기 위해 관리 했습니까? – Cristiano

답변

3

입니다 템플릿을로드 할 때 '캐시 된'변수를 지울 필요가 있습니다.

if (window.addthis) { 
     window.addthis = null; 
     window._adr = null; 
     window._atc = null; 
     window._atd = null; 
     window._ate = null; 
     window._atr = null; 
     window._atw = null; 
     } 
    var uniqueUrl = "http://s7.addthis.com/js/300/addthis_widget.js#pubid=XXX"; 
    $.getScript(uniqueUrl) 
    .done(function(script) { 
     addthis.init(); 
    }); 
관련 문제