My drag and drop functionality works with the following html section:
<div class="outer" ondragover="event.preventDefault();">
@foreach (CustomObject o in ObjectList)
{
<div draggable="true" @key="o.Rank" @ondrag="@(()=> StartDrag(o))" @ondrop="@(()=> Drop(o))" class="inner">
...
</div>
}
</div>
But I want to make "draggable" work with a variable so I can turn it on and off.
In my code section I add:
private bool isDraggable = true;
All of the following don't allow for the drag and drop functionality to work:
draggable="isDraggable"
draggable="@isDraggable"
draggable=isDraggable
draggable=@isDraggable
Is there something I am missing here? or can you just flat out not make draggable work with a variable??
Finally figured it out:
draggable="@isDraggable.ToString()"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.