1

I'm using Jquery tabs to display some contents from a content query webpart (used this article:http://www.sharemuch.com/2014/11/17/quickly-turning-your-content-query-web-part-display-into-a-jquery-tabs/).

My goal is to filter a content query web part using url query string (easy) but I want to use those tabs as filters (presentation).

If I click on a tab I want to reload the same page + url parameter (ex: test.aspx?tabFilter=1 --> click on tab 1)

I will use this parameter with my cqwp.

I'm not able to create the href in the tab name with the jquery.

The page seems to be looping...

anybody could help ?

<script>
 $(function() {
 var tabCount = 0;
 $(".dfwp-item div.groupheader").each(function() {
 $("#tabs ul").append("<li><a href='"+encodeURI(test.aspx?Myfilter="+$(this).text())+"'>" + $(this).text()+"</a></li>");
 $("#tabs").append("<div id='tabs-"+tabCount+"'>"+"<p>&nbsp;</p></div>");
  $(this).parent().hide();
 tabCount = tabCount+1;
 });
$("#tabs").tabs({
    select: function (e, ui) {
        window.location.href=ui.tab.href;
    }
});
 });
 </script>

<div id="tabs">
 <ul>
 </ul>
 </div>
1

This looks to be malformed

$("#tabs ul").append("<li><a href='"+encodeURI(test.aspx?Myfilter="+$(this).text())+"'>" + $(this).text()+"</a></li>");

try:

 $("#tabs ul").append("<li><a href='"+encodeURI("test.aspx?Myfilter="+$(this).text())+"'>" + $(this).text()+"</a></li>");
  • Thank's but that doesn't help. – Snake Feb 17 '15 at 9:25
0

I finally found the solution using the activate event of the tabs:

<script>

 $(function() {
 var tabCount = 0;
 $(".dfwp-item div.groupheader").each(function() {
$("#tabs ul").append("<li><a href='#tabs-"+tabCount+"'>" + $(this).text

()+"</a></li>");

 $("#tabs").append("<div id='tabs-"+tabCount+"'>"+"<p>&nbsp;</p></div>");
  $(this).parent().hide();
 tabCount = tabCount+1;
 });

$("#tabs").tabs({
        activate: function(event, ui){
          console.log(ui.newTab.index());
           console.log (encodeURI("test.aspx?myFilter="+ui.newTab.text()));            
           window.location.href=encodeURI("test.aspx?myFilter="+ui.newTab.text());
        },
});


 });
 </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.