0

jquery を使用して、ポートレット/ウィジェット スタイルのインターフェイスを実装しようとしています。3 つの列があり、それらの間でドラッグ アンド ドロップします。IE6で動作しないという問題を除いて、ほぼ完全に動作しています

(function($) {
  $.fn.portlet = function() {
    return this.each(function() {
      $(this).sortable({
        connectWith: ['.portletColumn'],
        handle: 'h3',
        placeholder: 'drop',
        forcePlaceholderSize: true,
        start: StartDrag,
        stop: StopDrag
      });
    });
  };

  function StartDrag(event, ui) {
    try {
      //in ui.helper[0] is null and hence the issue
      //alert(ui.helper[0]);
      currentlyDraggedNode = this;
      alert(currentlyDraggedNode);
      ('.drop').css('height', jQuery(ui.helper[0]).outerHeight() + 'px');
      $('.portletColumn').css('background-color', '#eee');
    } catch (ex) { }
  }

  function StopDrag(event, ui) {
    try {
      $('.portletColumn').css('background-color', '#fff');
      UpdateOrder();
    } catch (ex) { }
  }

  function GetString(selector) {
    var querystring = "";

    $(selector).each(function() {
      var id = $(this).attr('id');

      if (id && id != '') {
        querystring += id + ';'
      }
    });

    return querystring;
  }

  function UpdateOrder() {
    var querystring = GetString('#col1 .portletColumn .portlet') + '|;' + GetString('#col2 .portletColumn .portlet') + '|;' + GetString('#col3 .portletColumn .portlet');
    $.get("/handlers/portlet.ashx?" + querystring);
  }
})(jQuery);
4

1 に答える 1

1

jQuery(ui.helper[0])代わりに を使用している理由をお尋ねしてもjQuery(ui.helper)よろしいですか? jQuery UI のソースにあるすべてのコードは、そのように参照しています。

于 2010-03-29T21:56:00.010 に答える