2015-11-23 2 views
0

Я пытаюсь перетащить и сортировать, чтобы работать вместе, но не повезло.jQuery UI перетаскиваемый и сортируемый не работает

Смотрите это gist для HTML кода

revelant Javascript является:

function makeDraggable(theID) { 
$('ul#elements > li.element').each(function() { // TODO: also for templates 
    $(this).draggable({ 
     helper: function() { 
      return $('<div style="height: 100px; width: 300px; background: #F9FAFA; box-shadow: 5px 5px 1px rgba(0,0,0,0.1); text-align: center; line-height: 100px; font-size: 28px; color: #16A085"><span class="fui-list"></span></div>'); 
     }, 
     revert: 'invalid', 
     appendTo: 'body', 
     connectToSortable: theID, 
     stop: function() { 
      pageEmpty(); 
      allEmpty(); 
     }, 
     start: function() { 
      // switch to block mode 
      $('input:radio[name=mode]').parent().addClass('disabled'); 
      $('input:radio[name=mode]#modeBlock').radiocheck('check'); 

      // deactivate design mode 
      $('#pageList ul li iframe').each(function() { 
       this.contentDocument.designMode = "off"; 
      }); 
     } 
    }); 
}); 
$('#elements li a').each(function() { 
    $(this).unbind('click').bind('click', function(e) { 
     e.preventDefault(); 
    }); 
}); 
} 
function makeSortable(el) { 

el.sortable({ 
    revert: true, 
    tolerance: 'pointer', 
    placeholder: "drop-hover", 
    beforeStop: function(event, ui) { 
     console.log('beforeStop'); 
     var attr = ui.item.attr('data-frames'); 
     if (typeof attr !== typeof undefined && attr !== false) { // template, build it 
      $('#start').hide(); 

      // clear out old possible frames 
      $('#pageList ul:visible li').each(function() { 
       $(this).remove(); 
      }); 

      // create the new frames 
      frameIDs = ui.item.attr('data-frames').split('-'); 
      heights = ui.item.attr('data-heights').split('-'); 
      urls = ui.item.attr('data-originalurls').split('-'); 
      for (x = 0; x < frameIDs.length; x++) { 
       toInsert = $('<li><iframe src="' + laroute.route('api.sites.getframe', {id: frameIDs[x]}) + '" frameborder="0" scrolling="0" data-originalurl="' + urls[x] + '"></li>'); 
       $('#pageList ul:visible').append(toInsert); 
       theHeight = heights[x]; 
       toInsert.find('iframe').uniqueId().height(theHeight + "px"); 
       toInsert.height(theHeight + "px"); 
       // add a delete button 
       delButton = $('<button type="button" class="btn btn-danger deleteBlock"><span class="fui-trash"></span> remove</button>'); 
       resetButton = $('<button type="button" class="btn btn-warning resetBlock"><i class="fa fa-refresh"></i> reset</button>'); 
       htmlButton = $('<button type="button" class="btn btn-inverse htmlBlock"><i class="fa fa-code"></i> source</button>'); 
       frameCover = $('<div class="frameCover"></div>'); 
       frameCover.append(delButton); 
       frameCover.append(resetButton); 
       frameCover.append(htmlButton); 
       toInsert.append(frameCover); 

       // dropped element, so we've got pending changes 
       setPendingChanges(true); 

       // setup editor events 
       toInsert.find('iframe').load(function() { 
        setEditorEvents($(this)); 
        heightAdjustment($(this).attr('id'), true); 
       }); 
       allEmpty(); 
      } 

      // set the tempateID 
      templateID = ui.item.attr('data-pageid'); 

      // make sure nothing gets dropped in the list 
      ui.item.html(null); 

      // delete drag place holder 
      $('body .ui-sortable-helper').remove(); 
     } else { 
      alert('imagge'); 
      if (ui.item.find('.frameCover > button').size() == 0) { 
       // image thumbnails 
       console.log(ui.item); 
       theHeight = ui.item.find('img').attr('data-height'); 

       ui.item.html('<iframe src="' + ui.item.find('img').attr('data-srcc') + '" scrolling="no" data-originalurl="' + ui.item.find('img').attr('data-srcc') + '" frameborder="0"><iframe>'); 

       ui.item.find('iframe').uniqueId(); 
       ui.item.find('iframe').height(theHeight + "px"); 
       ui.item.find('iframe').css('background', '#ffffff url(' + baseUrl + 'images/loading.gif) 50% 50% no-repeat'); 
       ui.item.find('iframe').load(function() { 
        heightAdjustment(ui.item.find('iframe').attr('id'), true); 
       }); 

       // add a delete button 
       delButton = $('<button type="button" class="btn btn-danger deleteBlock"><span class="fui-trash"></span> remove</button>'); 
       resetButton = $('<button type="button" class="btn btn-warning resetBlock"><i class="fa fa-refresh"></i> reset</button>'); 
       htmlButton = $('<button type="button" class="btn btn-inverse htmlBlock"><i class="fa fa-code"></i> source</button>'); 
       frameCover = $('<div class="frameCover"></div>'); 
       frameCover.append(delButton); 
       frameCover.append(resetButton); 
       frameCover.append(htmlButton); 
       ui.item.append(frameCover); 

       // dropped element, so we've got pending changes 
       setPendingChanges(true); 
      } else { 
       //sorted 
       ui.item.find('iframe').load(function() { 
        $(this).contents().find(pageContainer).html(frameContents) 
       }) 
      } 
     } 
    }, 
    stop: function() {}, 
    start: function(event, ui) { 
     if (ui.item.find('.frameCover').size() != 0) { 
      frameContents = ui.item.find('iframe').contents().find(pageContainer).html(); 
     } 
    }, 
    over: function() { 
     $('#start').hide(); 
    } 
}); 
} 

makeSortable($('#page1')); 
makeDraggable('#page1'); 

Я положил все HTML, потому что, когда я извлечь только revelant части работает из коробки, но когда, как не работает.

Может ли кто-нибудь указать мне, что я делаю неправильно? Я на 3 дня искал, пытался, смотрел и не везло.

Update 1

раздел uselees HTML от сути, код синтаксиса фиксированного Question в

Я отметил, что этот вопрос, скорее всего, сортируется, не зная, что перетаскивание является парить его (или наоборот , draggable, не зная, является зависанием сортировки)

ответ

0

Нашел проблему сам, это конфликт между Flat-UI js и jQuery-UI js, только переупорядочение включений решает проблему.

Неправильно: (вызывая конфликт)

jquery 
jquery-ui 
flat-ui 

Правильно: (конфликт уходит)

jquery 
flat-ui 
jquery-ui 

Пожалуйста, обратите внимание, что на сути этих скрипты включены в 3rdparty.js (вперемешку с использованием Gulp)

Смежные вопросы