2012-03-16 134 views
1

我要像做包括JavaScript變量ExpressionEngine路徑標籤

$('a.filter-link').click(function(e) { 
      e.preventDefault(); 
      var that = $(this), 
       categoryId = that.data('id'), 
       categoryName = that.data('catname'); 
      $('div.results').load("{path='ums/performances-results/<I WANT var categoryName here>'}", {category: categoryId, ajax: true}); 
     }); 

我如何變呢?這是在模板頁面內聯,所以我知道{path ='ums/performance-results'}有效,但我需要這個依賴於last_segment變量。我只想渲染一個特定的模板,因此在過濾結果集時不必刷新整個頁面。謝謝。

+0

我們可以看到用戶點擊的鏈接是什麼樣子。另外,是否有一個原因是你將這個'重新命名爲'那個'? – 2012-03-17 02:12:21

回答

0

不能混合EE標籤和JavaScript。部分EE代碼庫嘗試識別JavaScript大括號和EE括號之間的區別。有時候它會失敗,所以我們必須通過構建EE位來幫助它,而不是與類似的JS括號混合。

以下工作?

$('a.filter-link').click(function(e) { 
      e.preventDefault(); 
      var that = $(this), 
       categoryId = that.data('id'), 
       categoryName = that.data('catname'); 
      var path = "{path='ums/performances-results/'}"+categoryName; 
      $('div.results').load(path, {category: categoryId, ajax: true}); 
}); 

你是否還嘗試過把/ ums/performance-results /而不是在EE中使用路徑調用?

0

我沒有測試過,但不妨一試:

$('a.filter-link').click(function(e) { 
       e.preventDefault(); 
       var that = $(this), 
        categoryId = that.data('id'), 
        categoryName = that.data('catname'); 
       $('div.results').load("{path='ums/performances-results/'}"+categoryName, {category: categoryId, ajax: true}); 
      }); 
+0

不,沒有工作。我在想,categoryName需要在某種程度上。 – LOLapalooza 2012-03-16 18:35:49

+0

可能需要轉義變量: '$('a.filter-link')。click(function(e){e.preventDefault(); var that = $(this), categoryId = .data('id'), categoryName = that.data('catname'); $('div.results')。load(「{path ='ums/performance-results /'+'categoryName \' }「,{category:categoryId,ajax:true}); }); ' – Vimalnath 2012-03-17 06:17:21