2012-10-19 2 views
0

http://medfor.petersenuploads.co.uk/product.php/698/2/clear-ps-honey-jar-with-metal-screw-cap설정 선택 옵션은 전체 가격 탭에서

클릭 jQuery를 사용하고 옵션 중 하나를 '추가'속성. 아래의 선택 상자 값을 설정해야하지만 변경되지는 않습니다. 이벤트가 올바르게 실행 중이지만 선택한 항목은 변경되지 않습니다.

데이터 유형 문제 일 수 있습니까? 대신

.attr('selected',true); 

$('a.addspecific').live(
    'click', function(e) { 
     e.preventDefault(); 
     //console.log($(this).data('sterility')); 
     console.log("IN"); 
     //Update dropdowns for JShop functionality 
     $('#capacity').find("option").filter(function() { 
      return $(this).text() == $(this).data('capacity'); 
     }).attr('selected',true); 
     console.log($(this).data('capacity')); 
     $('#sterility').find("option").filter(function() { 
      return $(this).text() == $(this).data('sterility'); 
     }).attr('selected',true); 
     console.log($(this).data('sterility')); 
     $('#labeltype').find("option").filter(function() { 
      return $(this).text() == $(this).data('labeltype'); 
     }).attr('selected',true); 
     console.log($(this).data('labeltype')); 
     $('#itemspercase').find("option").filter(function() { 
      return $(this).text() == $(this).data('itemspercase'); 
     }).attr('selected',true); 
     console.log($(this).data('itemspercase')); 
     console.log("OUT"); 


    } 
+0

정확하게는 어떻게해야 무엇 ?? –

+1

@ Sushanth - 항목의 추가 버튼을 클릭하면 제품 선택 상자의 메뉴가 모두 해당 항목과 일치하도록 변경됩니다. – Barmar

+0

탭에서 '추가'버튼을 클릭하면 하단의 옵션이 올바른 설정으로 설정되므로 50ml | Sterile | No Label | 314 옵션을 클릭하면 드롭 다운이 적절하게 변경됩니다. – Jeepstone

답변

3

은이 컨텍스트를 사용해보십시오, 그것을 시도 :

console.log("IN"); 
var thes = this; 

$('#capacity').find("option").filter(function() { 
    return $(this).text() == $(thes).data('capacity'); 
}).attr('selected',true); 
+0

아 맞다. – Jeepstone

0

실패한다

.prop('selected',true); 
+0

효과가없는 것 같습니다. – Jeepstone

관련 문제