Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:08:36+00:00 2026-06-01T07:08:36+00:00

I’m having a problem whereby I am trying to load some html onto a

  • 0

I’m having a problem whereby I am trying to load some html onto a page using jQuery.

The content itself loads fine, but what I am trying to do is make that content ‘draggable’ using jquery ui.

The problem that I am having is that when I call the function to make the content draggable, it hasn’t loaded yet, so nothing is being made draggable.

I tried, with some success, adding a setTimeout before the function call, this left it working, but not how i’d like it. The setTimeout wouldn’t work on slow internet connections, or when the site is loading slowly, as it’s too low. But if i set it too high then there’s a long wait before the content is moveable.

I was wondering if there’s a way to detect whether the content has loaded before calling the function?

My code:

  $(".naviitem").click(function(){     //When icon is clicked
    var i = $(this).attr('id');        //Get id of clicked icon
    $.when(load(i)).then(makeDrag());  //Load page then call makeDrag (Doesn't function properly)
  });


function load(i){

      $.get('wnd/' + i + '.htm', {}, function(data) {  //This all works
        var $response = $('<div />').html(data);
        var $load = $response.find('#p' + i);
        $('#page').append($load);
      },'html');
  }

 function makeDrag(){
      //does something here
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:08:38+00:00Added an answer on June 1, 2026 at 7:08 am
    $.when(load(i)).then(makeDrag());
    

    This should be:

    $.when(load(i)).then(makeDrag); // Note the lack of () after makeDrag
    

    You need to pass a function to .then, passing makeDrag() passes the result of that function, not the function itself.

    Also, load should return $.get for $.when to work.

    function load(i){
          return $.get('wnd/' + i + '.htm', {}, function(data) {  //This all works
            var $response = $('<div />').html(data);
            var $load = $response.find('#p' + i);
            $('#page').append($load);
          },'html');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.