The angularjs ui-sortable feature is experiencing an issue where methods cannot be called on sortable before initialization. The specific method 'refresh' was attempted to be called prematurely

I'm attempting to sort a list, where I retrieve the elements from a database but...

Error: unable to call methods on sortable before initialization; tried calling method 'refresh'

This is 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 here's my controller:

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

The getMenu() function is defined as follows:

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

If I retrieve the menu items without using a REST service and just bind them directly, everything works fine with no errors! Any ideas why?


Problem identified: The issue was caused by mistakenly importing angularjs.js library twice.

Answer №1

Issue resolved: I mistakenly imported angularjs.js twice.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I use JavaScript to update the content inside HTML tags with a specific string?

I have a situation where I need to replace a string in two different ways Input: Parameters-->string, AnnotationName, input Case 1: And I should input <i>Annotaion</i> as <b>input</b> Output : { displayData: `And I should inp ...

The function update in chart.js is not available

I encountered an issue while trying to update my chart. When I clicked the button, an error message popped up saying TypeError: pieChartData.update is not a function const LatestSales = props => { const {pieChartData} = props; const toggle ...

Updating a JSON file in AngularJS is a common task that many developers encounter

I'm working with a json file and currently only have the ability to read from it, not update it. In my service class, I am loading the json file using the code snippet below: loadjsonfile:function(){ var promise= $http.get('json/items.json&apos ...

Combining both the Javascript and PHP components of the Facebook SDK

I recently integrated the JavaScript version of Facebook SDK, but now I'm unsure how to also integrate the PHP version without causing any conflicts. Here are my questions: If I implement the PHP SDK from Facebook, is there a way to detect if the J ...

What steps should I take to make my Vue JS delete function operational?

As I work on developing my website, I've encountered some challenges. Being new to coding, I'm struggling with creating a functional delete user button. When I click delete, it redirects me to the delete URL but doesn't remove the entry from ...

Selenium Assistance: I'm encountering a scenario where on a webpage, two elements share the same Xpath, making it difficult to differentiate them based on even

At index [1], both elements are identified, but at index [2], nothing is identified. The key difference between the two is that one has display:none, and the other has display:block. However, their involvement in determining these fields is minimal due to ...

Transmitting information securely and remotely between two online platforms

I own two websites and another at When a user clicks on something on example1.com, I want it to trigger a popup from example2.com. Then, I need to send some data back to example1.com using GET parameters and be able to detect it using jQuery or JavaScrip ...

What are some creative ways to utilize postMessage instead of relying on nextTick or setTimeout with a zero millisecond delay?

I just came across a theory that postMessage in Google Chrome is similar to nextTick. This idea somewhat confused me because I was under the impression that postMessage was primarily used for communication between web workers. Experimenting with expressio ...

Using the Facebook marketing API requires a valid Instagram account ID to be provided as a parameter

I've been exploring the capabilities of the Facebook Marketing API once again. After successfully creating Facebook ads using my Node.js app, I now have my sights set on Instagram. My current call to create an AdCreative looks like this: fb.api(&ap ...

Guide to refreshing a localStorage variable before transferring it to an Ajax request

I have a scenario where I need to update the localStorage value when an option is clicked from a list. The data-id value of the clicked option should be stored in localStorage and then sent through an Ajax call. However, the issue I am facing is that the l ...

The 'otherwise' controller in AngularJS does not execute when the resolution in another controller has not been successful

Imagine having routes set up in the configuration: $routeProvider .when('/person/:person_id', { controller: 'person', templateUrl: 'partials/person.html', resolve: { data: ['api', '$route', ...

Pressing the Button Increases the Counter, However the Counter Resets After

My goal is to create a basic counter with increment and reset buttons. When I click on the increment button, the counter properly goes from 0 to 1 (I can confirm this by checking the console log in Chrome). The issue arises when, after incrementing, the c ...

Meteor: How to upload an image file by utilizing the FileReader on the client side and Npm requiring "fs" on the server side

I am facing difficulties trying to upload an image file to my public/ directory using a standard <input type="file"> element. This is the code snippet causing issues: "change .logoBusinessBig-upload":function(event, template){ va ...

Applying a class to an element in VueJS is not functioning as expected

My goal is to assign the class .testcolor to the div element when testvalue is true, and apply no class when it's false. I encountered an issue where the getClass method does not get called when added to :class attribute, but works fine when called f ...

Passing events from Vue to child components

Looking for a way to make clicking on the outer pill element have the same effect as clicking on the checkbox itself? Check out this HTML code that renders these little boxes: https://i.sstatic.net/hspnF.png <div class="token-checkboxes"> <spa ...

I'm facing some uncertainties with a couple of AngularJS code snippets

At my workplace, I am tasked with making modifications to an angularjs project. However, I find the code quite complex and challenging to fully comprehend: app.controller("complementsController", function($scope, $rootScope, $mdSidenav, $timeout, $localSt ...

Ways to execute a script from termly on NextJS using JSX

I've been utilizing termly to assist in creating legal terms for a website I'm developing. They provided me with some HTML containing a script, but I am struggling to get it to execute on a page in JSX. I attempted to use both Script and dangerou ...

What is the method for inserting data into an array of objects in JavaScript?

I have a question regarding how to push/replace data into an object of an array of objects. Please excuse any mistakes in my grammar. Here is my dummy data: const dummyData = { id: 1, daerah: "Bandung", date:"1668790800000& ...

Utilizing External Libraries Added Through <script> Tags in React

My goal is to develop a Facebook Instant HTML5 application in React. Following their Quick Start guide, Facebook requires the installation of their SDK using a script tag: <script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></scrip ...

Switch up the color of checkboxes with a dropdown menu option

I have an HTML dropdown code and I am trying to trigger a click event when a specific value is selected. Once this value is clicked, I want some checkboxes to change color. <select> <option value="calculate">calculate</option> ...