Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular drag and drop - how to pass a parameter to the onStart callback function

THE SITUATION:

I have an app that make use of angular drag and drop.

Everything is working fine except one thing. I need to pass one parameter in the onStart callback function, but i don't know how. I search around and try several possibilities but without success. The function itself is working, has been called and properly executed, the only problem i have is to pass a parameter to it.

THE CODE:

In this example there one of the attempt i have made.

    <div class="col-sm-4">

        <div class="thumbnail" data-drop="true" ng-model='todo_list' jqyoui-droppable="{multiple:true, onDrop:'update_item()'}">
            <div class="caption">
                <div class="btn btn-info btn-draggable" ng-repeat="item in todo_list track by $index" ng-show="item.title" data-drag="true" data-jqyoui-options="{revert: 'invalid'}" ng-model="todo_list" jqyoui-draggable="{index: {{$index}}, onStart:'set_board_item_id_panel(event, ui, {board_item_id: item.board_item_id})'}">{{item.title}}</div>
            </div>
        </div>

    </div>

THE QUESTION:

How can i pass a parameter in the callback function of angular drag and drop?

Thank you very much!

like image 733
FrancescoMussi Avatar asked Dec 30 '14 11:12

FrancescoMussi


1 Answers

You don't need to pass in parameters event and ui, those are the first 2 default arguments.

Replace ...

onStart:'set_board_item_id_panel(event, ui, {board_item_id: item.board_item_id})'

With ...

onStart:'set_board_item_id_panel({board_item_id: item.board_item_id})'

Then in your Controller do this ...

....
$scope.set_board_item_id_panel = function (event, ui, board_item_id) {
    console.log(board_item_id);
}
....
like image 82
dcodesmith Avatar answered Oct 24 '22 08:10

dcodesmith