Ошибка IE в строке jquery 4618 - PullRequest
       14

Ошибка IE в строке jquery 4618

0 голосов
/ 26 апреля 2010

Я пытаюсь сохранить некоторую информацию о css в куки с помощью приведенного ниже скрипта jquery.

Все отлично для Firefox, однако IE выдает ошибку в строке jquery 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*/

Ответы [ 2 ]

0 голосов
/ 26 апреля 2010

Я думаю, вам нужно обернуть оставшиеся ваши вызовы this в части загрузки и сохранения в объект jquery. Вы делаете это на первой линии, но вы не делаете это на остальных. Например, этот код:

// 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 голосов
/ 26 апреля 2010

Вы пытаетесь использовать функции savePos и savePot, прежде чем фактически объявите их. Вы не можете связать функцию с событием, если функция еще не существует.

Поместите объявления функций savePos и savePot перед точкой, где вы привязываете их к событиям.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...