2012-05-27 2 views
2

이 코드는 필터링 할 수있는 포트폴리오입니다. 원래 나는 다음 링크와 이전 링크에 대해 PHP를 가지고 있었지만 포트폴리오가 필터링되면 다음 필터링 된 객체를 찾지 못했습니다. 필터가 목록 항목을 서로 옆에 배치하여 결과를 얻기 위해 next()를 사용했음을 발견했습니다. 그러나 링크가 제대로로드되지 않습니다. thickbox를로드하는 동일한 페이지에 대한 링크입니다. 성공적으로 새 창에서 열어 창 URL에 추가 할 수있게되었지만 작동시키려는 주사위는 없습니다. 여기에 해당 포트폴리오의 주소가 있습니다. 동일한 페이지 내 링크로드 jQuery

$(document).ready(function(){ 
    $(".portfolio-next").click(function(e) { 
    var $this = $(this); 
    if($this.data('clicked', true)) { 
    var namer = $(this).attr('value'); 
    var url = $(this).parents('body').children('#wrap').children('#inner').children('#content-sidebar-wrap').children('#content').children('ul#portfolio-list').children().next('.portfolio-item-' + namer).nextAll('.portfolio-item:not(:.isotope-hidden)').attr('id'); 
     window.location.load(url); 
     e.preventDefault(); 
    } 
     }); 
}); 

http://blurosemedia.com/portfolio

가 나는 Thickbox와 코드가 자동으로 페이지 하단에 보여주기 때문에 다우 트리를 모든 방법을 상승했다. 두꺼운 상자를로드하기 위해서 클래스 = "thickbox"가 있어야한다고 생각한 한 가지 가능한 솔루션이 있습니다. 어떻게 든로드 (url) .withClass ('thickbox')가 작동한다고해도 구문이 어떻게되어야하는지 확신 할 수 있습니다.

답변

0

당신은 밖으로 정렬하는 많은 것들을 가지고 있지만, 여기 당신이 올바른 경로로가는 데 도움이되는 몇 가지 정보입니다 :

1)

window.location.load가 종료, 당신은 무엇을 찾고되지 않습니다는 대한이 window.location.href입니다 :

는 참조 문서를 문서 from MDN

를 참조 from MSDN

0 예

, 또한window.location.href = url;


2)

문자로 시작해야

ID와 NAME 토큰 ([A-ZA-Z]) 및 숫자 ([0-9]), 하이픈 ("-"), 밑줄 ("_"), 콜론 (":") 및 마침표 (".

#으로 시작하는 ID로 li을 설정합니다.

자세한 내용은 this link을 참조하십시오. 이것에 대한

해결 방법 :

<li id="#TB_inline?height=450&width=900&inlineId=id-3" class="portfolio-item design portfolio-item-3 isotope-item">...</li> 

이 될 수 :

<li class="portfolio-item design portfolio-item-3 isotope-item"> 
<span style="display:none;">#TB_inline?height=450&width=900&inlineId=id-3</span> 
</li> 

3)

당신은 위아래 아무 이유없이 DOM을 여행하고있다. 아이템의 래퍼에 ID가 있으므로 (#portfolio-list), 대상을 타겟팅하고 시작할 수 있습니다!또한

,

('.portfolio-item:not(:.isotope-hidden)') 

는 같아야:not(:something):checked

보기 원한다면, 소정의 상태를 갖는 요소를 대상으로 사용하여

('.portfolio-item:not(.isotope-hidden)') 

자세한 내용은!


4)

변수 namer가 열린 항목의 현재 ID를 가져옵니다, 당신은 다음 단계로 전달하려는 때문에, 당신의 코드가된다 :

$(document).ready(function(){ 
    $(".portfolio-next").click(function(e) { 
    e.preventDefault(); 

    var $this = $(this); 

    var namer = parseInt($this.attr('value'))+1; 
    var url = $this.attr("href"); 
     url = url.substring(0, url.indexOf('=id')); 

    window.location.href(url+"=id"+namer); 
    }); 
}); 

참조 이 Fiddle Example!

태그 a에는 value이라는 특성이 없으므로 잘못된 태그입니다.

자세한 내용은 this link을 참조하십시오.

0

감사합니다. jQuery를 처음 보게 된 것은 이번이 처음입니다. 이것은 내가 생각해 낸 것입니다 :

<?php echo '<a href="#TB_inline?height=450&amp;width=900&amp;inlineId=id-" class="thickbox  
portfolio-previous" value="'; echo $portnum; echo '">Previous</a>';echo '<a 
href="#TB_inline?height=450&amp;width=900&amp;inlineId=id-" class="thickbox portfolio- 
next" value="'; echo $portnum; echo '">Next</a>';?> 

    //Next Portfolio Button 
$(".portfolio-next").hover(function(e) { 
e.preventDefault(); 
var $this = $(this); 
//Get the value of the link which is the same value as the current list item 
var namer = parseInt($this.attr('value')); 
//Find the current div in the dom and find the list item id next to it 
var falcon = $('ul#portfolio-list').children('.portfolio-item-' +  
namer).nextAll('.portfolio-item:not(:.isotope-hidden)').attr('id'); 

//Find the href tag id and add the value from falcon 
var url = $this.attr("href"); 
url = url.substring(0, url.indexOf('=id')); 
if(falcon === undefined) { 
var falcon2 = $('ul#portfolio-list').children('.portfolio-item-' + 
namer).prevAll('.portfolio-item:not(:.isotope-hidden):first').attr('id'); 
$(this).attr('href', url+"=id-"+falcon2); 
}else{ 
$(this).attr('href', url+"=id-"+falcon); 
return; 
} 
}); 

//Previous Portfolio Button 

$(".portfolio-previous").hover(function(e) { 
e.preventDefault(); 
var $this = $(this); 
//Get the value of the link which is the same value as the current list item 
var namer = parseInt($this.attr('value')); 
//Find the current div in the dom and find the list item id next to it 
var falcon = $('ul#portfolio-list').children('.portfolio-item-' +  
namer).prevAll('.portfolio-item:not(:.isotope-hidden)').attr('id'); 

//Find the href tag id and add the value from falcon 
var url = $this.attr("href"); 
    url = url.substring(0, url.indexOf('=id')); 
    if(falcon === undefined) { 
    var falcon2 = $('ul#portfolio-list').children('.portfolio-item-' + 
namer).nextAll('.portfolio-item:not(:.isotope-hidden):last').attr('id'); 
    $(this).attr('href', url+"=id-"+falcon2); 
}else{ 
$(this).attr('href', url+"=id-"+falcon); 
return; 
} 
}); 

어떻게 작동합니까?하지만 최적화 방법에 대한 제안은 크게 감사하겠습니다.

관련 문제