How to change attribute value on event ionic

Hello

I am working on drag drop application in ionic. I am using jQuery UI for drag and drop events.

 <li on-hold="longPressed($event )" on-double-tap="onDoubleTap(item)" data-zone="z1" data-id="{{item.id}}" class="listitem" ng-click="z1ElementClicked(item)" ng-repeat="item in handle.z1level" jqyoui-droppable="{onDrop : 'onDropp(event , ui)'  }" data-drop="true" class="btn btn-primary" data-drag="false" data-jqyoui-options="{helper: 'clone', revert: 'invalid', appendTo: 'body'}"  jqyoui-draggable="{onDrag : 'onDragg(event)' , animate:true}" ><a>{{item.name}}</a></li>

This is my element i am dragging what i want is when user long press on screen i want data-drag=“false” change to data-drag=“true”

   $scope.longPressed = function(event){

   console.log($(event.target).parent().data("drag"));
   $(event.target).parent().data("drag" , "true");
    console.log($(event.target).parent().data("drag"));
 }

I am using this code to change the attributes and its working fine but problem is my element is not dragging even after i have changed the attributes is there any way of reloading dom after changing element attribute.?

use the enable/disable methods
http://api.jqueryui.com/draggable/#method-enable

Hello @bengtler

Thanks For the reply

 $scope.longPressed = function(event) {
 $(event.target).draggable( "enable" );

}

This is what is just try to do can you give me small example how can i use disable function initiallly my data-drag attribute is false. on long press i $(event.target).draggable( “enable” );
inserted this but its not working

Thanks

Ok i just tried $(event.target).parent().draggable( “enable” );

but i have to click again to drag what i want is when use long hold on li element i want to make it draggable same time and on release disable it.

@bengtler actually its reinitializing draggable again is it possible to just reload when i am changing li element attribute? i am using angular-dragdrop directive for this.

thanks

i think i used it once… long time ago to enable it on the fly

But i do not understand you: "its reinitializing draggable again"
Does it automatically gets reinitialized or what?