2010-04-26 2 views
0

아래 jquery 스크립트를 사용하여 일부 CSS 정보를 쿠키에 저장하려고합니다. 난 당신이 실제로 선언하기 전에 기능 savePossavePot을 사용하려는jquery IE 오류 4618

jQuery(document).ready(function() { 

    // cookie period 
    var days = 365; 

    // load positions and z-index from cookies 
    $("div[id*='tqitem']").each(function(index){ 
    $(this).css("left", 
     $.cookie("im_" + $(this).attr("id") + "_left")); 
    $(this).css("top", 
     $.cookie("im_" + this.id + "_top")); 
    $(this).css("zIndex", 
     $.cookie("tqz_" + this.id + "_zIndex")); 
    }); 


    // bind event 
    $(".pagenumbers").draggable({cursor: "move"}); 
    $("div[id*='tqitem']").bind('dragstop', savePos); 
    $("div[id*='tqitem']").bind('dragstop', savePot); 


    // save positions into cookies 
    function savePos(event, ui){ 
    $.cookie("im_" + $(this).attr("id") + "_left", 
     $(this).css("left"), { path: '/', expires: days }); 
    $.cookie("im_" + this.id + "_top", 
     $(this).css("top"), { path: '/', expires: days }); 
    $.cookie("im_" + this.id + "_zIndex", 
    $(this).css("zIndex"), { path: '/', expires: days }); 
    }; 

var thiss = $("div[id*='tqitem']"); 

function savePot(){ 
     $("div[id*='tqitem']").each(function (i) { 
      $.cookie("tqz_" + $(this).attr("id") + "_zIndex", 
    $(this).css("zIndex"), { path: '/', expires: days }); 
     }) 
}; 

}); 



/*ADDITIONAL INFO: 

SCRIPT HIERARCHY 

Jquery itself 
Jquery ui 
Jquery cookie plugin 
Save cookies js 

no matter how i ordered them the result did not change*/ 

답변

0

당신은 나머지 부분을 jwery 객체로 로딩하고 저장하는 부분에 포장해야한다고 생각합니다. 첫 번째 줄에서는 작업을 수행하지만 나머지 작업에서는 수행하지 않습니다. 예를 들어,이 코드 :

// load positions and z-index from cookies 
    $("div[id*='tqitem']").each(function(index){ 
    $(this).css("left", 
     $.cookie("im_" + $(this).attr("id") + "_left")); 
    $(this).css("top", 
     $.cookie("im_" + this.id + "_top")); 
    $(this).css("zIndex", 
     $.cookie("tqz_" + this.id + "_zIndex")); 
    }); 

은 다음과 같아야합니다

// load positions and z-index from cookies 
    $("div[id*='tqitem']").each(function(index){ 
    $(this).css("left", 
     $.cookie("im_" + $(this).attr("id") + "_left")); 
    $(this).css("top", 
     $.cookie("im_" + $(this).attr("id") + "_top")); 
    $(this).css("zIndex", 
     $.cookie("tqz_" + $(this).attr("id") + "_zIndex")); 
    }); 
+0

난 그냥 그것을 자신을 해결하고 해결로 답장을 돌아 왔지만 그래 그 문제이고, 덕분에 ...이를 사용했다. 이드는로드하는 동안 저장 및 attr.id 동안 –

0

이 파일을 포함 할 때마다

다, 파이어 폭스하지만 IE는 JQuery와 라인 4618에 오류가 발생합니다 완벽하게 괜찮습니다. 함수가 아직 존재하지 않으면 함수를 이벤트에 바인드 할 수 없습니다.

savePossavePot 함수 의 선언을 앞에 두어 이벤트에 바인딩하는 위치에 놓습니다.