Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i'm trying to do sorting list, i take the element from the db but..

Error: cannot call methods on sortable prior to initialization; attempted to call method 'refresh'

my html:

<div class="box-body" >
                    <div ng:controller="menuConfigCtrl">
                        <ul ui-sortable ng-model="menu"  >
                            <li ng:repeat="item in menu |filter:'all' | orderBy:'order':false" >{{item.Title}}</li>
                        </ul>
                    </div>
                </div>

and my controller:

function menuConfigCtrl($location,$scope, menuFactory) {    
    $scope.menu = [];
    menuFactory.getMenu().success(function(data){
        $scope.menu = data;
    }); 
}

my getMenu() is:

getMenu : function(){
       return $http({
            url: '/api/menuList',
            method: 'GET',
        });
},

if i get the menu not from a rest service, but binding it, everyting work without error! what can be?

solved. i imported 2 times angularjs.js :P

share|improve this question
 
Have you tried calling $scope.$apply(); after $scope.menu = data; –  Asok Jun 27 at 17:56
 
yes, and it return $digest already in progress and then. cannot call methods on sortable prior to initialization; attempted to call method 'refresh' –  justBorn Jun 27 at 17:59
 
I cant reproduce, can you create a fiddle that shows the issue ? Could start from here: jsfiddle.net/ncapito/MRUDW –  Nix Jun 27 at 18:00
 
the problem is that it return error just if i take my menu from a rest serive! so i don't know how to replace it.. –  justBorn Jun 27 at 18:01
 
@jusBorn I updated my fiddle, and still cant' reproduce ur issue. I plugged in a mock service, as well as the angular ui-sortable ... please try again, and if you can't reproduce we will need to close the question. –  Nix Jun 28 at 17:43
show 2 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.