schartier / angular-sortable

Angular directive that mimics the sortable jquery-ui component.
Other
27 stars 8 forks source link

Setting debugInfoEnabled(false) breaks the directive #12

Open Xandroid4Net opened 8 years ago

Xandroid4Net commented 8 years ago

Adding the following to your angular app breaks the directive

app.config(['$compileProvider', function ($compileProvider) { $compileProvider.debugInfoEnabled(false); }]);

Here is the change I added, it seems to work for me, but you may know of a better one.

function Sortable(element, options) { this.options = $.extend({ items: '.sortable', handles: null, zindex: '9000', dragX: true, dragY: true, onChange: null, onDragstart: null, onDrag: null, onDragend: null }, options);

    if (!this.id) {
        this.id = 0;
    }
    //var id = element.scope().$id; ---This is the line that causes the problem. scope() is not available when debugInfo is disabled.

    this.classes = {};
    for (var key in classes) {
        this.classes[key] = classes[key] + '-' + this.id;
    }

    this.id += 1;