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 7754579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:20:43+00:00 2026-06-01T12:20:43+00:00

I’m developing application using backbone.js & jquery. I have following code in model: runReport:

  • 0

I’m developing application using backbone.js & jquery. I have following code in model:

runReport: function() {
   this.set({generatingReport: true});      
   //long computation...
   this.set({generatingReport: false});     
}

and following code in corresponding view (in initialize function):

...
var that = this;
...

this.model.bind("change:generatingReport", function() {                     
    if(that.model.get("generatingReport") === true) {
        $("#report").empty().append("<h1>Generating report...</h1>").show(0);
        console.log("begin");
    } else if(that.model.get("generatingReport") === false) {
        $("#report").empty().append("<h1>Report generated</h1>").show(0);
        console.log("end");
    }
});

and here is code in view that run the action:

...
events {
    "click #btn-run": "runReport"
}
...
runReport: function() {
    this.model.runReport();
}

My problem is that that the “Generatin report…” message is not shown at all (log messages are printed). When the report is generated “Report generated” appears.

If I do following (see added alert in IF branch):

this.model.bind("change:generatingReport", function() {                     
    if(that.model.get("generatingReport") === true) {
        $("#report").empty().append("<h1>Generating report...</h1>").show(0);
        console.log("begin");
        alert("stop!");
    } else if(that.model.get("generatingReport") === false) {
        $("#report").empty().append("<h1>Report generated</h1>").show(0);
        console.log("end");
    }
});

then “Generating report…” is shown. In the “long computation…” part there is no hide jquery call that could possibly hide the message.

Any idea what is happening 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-01T12:20:45+00:00Added an answer on June 1, 2026 at 12:20 pm

    I think what’s probably happening here is that the browser never has a chance to update the UI. Your long computation is all happening in the event handler for a click event. The browser probably (I say “probably” a lot here because I’m not really an expert in browser threading models!) dispatches the click event to your Javascript code, and then waits for your event handler to finish before updating/redrawing the UI. In this case, you’re not yielding control (finishing) until the long process is over, so the UI only redraws itself once at the end. The DOM’s #report node is changing internally in response to your code, but it doesn’t have a chance to redraw itself on screen until after your process finishes. I don’t know if this is optimal, but something like this might help:

    runReport: function() {
      var self = this;
      this.set({generatingReport: true});
    
      // By calling delay, runReport() will exit immediately so UI can redraw
      _.delay(function() {
        //long computation...
        self.set({generatingReport: false});
      }, 50);
    }
    

    I’m just using underscore’s delay() function there to postpone the long processing for 50 milliseconds. By doing so, the runReport() function can immediately exit, the click event handler that started the whole chain of events can finish executing, and the UI can redraw itself to show the “Generating report…” message. After a very short (50 milliseconds) delay, the long computation will begin, and when it’s done, generatingReport will set to false and the UI will update again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to

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.