2012-03-16 74 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