最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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!

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!

Share Improve this question edited Dec 30, 2014 at 13:05 FrancescoMussi asked Dec 30, 2014 at 11:43 FrancescoMussiFrancescoMussi 21.6k40 gold badges129 silver badges181 bronze badges 2
  • It looks like you are missing the closing parenthesis for set_board_item_id_panel( ? – lbrazier Commented Dec 30, 2014 at 12:59
  • Thank you to notice it. It probably went away making many attempts. I edit the question. But still is not working. – FrancescoMussi Commented Dec 30, 2014 at 13:06
Add a ment  | 

1 Answer 1

Reset to default 9

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);
}
....
发布评论

评论列表(0)

  1. 暂无评论