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

  • Home
  • SEARCH
  • 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 6667011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:53:18+00:00 2026-05-26T02:53:18+00:00

I am stuck in this code: reload: function() { var self = this; $.when(self.unload()).then(function()

  • 0

I am stuck in this code:

reload: function() {
            var self = this;
            $.when(self.unload()).then(function() {
                self.load();
            });
        },
load: function() {
            var self = this;
            $.ajax({
                url: self.options.url,
                success: function(data) {
                    $.Deferred(
                        function(dfr) {
                            $.each(data, function() {
                                var div = $('<div></div>')
                                    .addClass('nw-item')
                                    .html('newsitem.ejs', this)
                                    .hide()
                                    .appendTo(self.element);
                                dfr = dfr.pipe(function() {
                                    return div.slideDown(self.options.speed);
                                });
                            });
                        }).resolve();
                }
            })
        },
unload: function() {
            var items = this.element.children('.nw-item').reverse(),
                self = this,
                udfd = $.Deferred(
                    function(dfr) {
                        $.each(items, function() {
                            var div = $(this);
                            dfr = dfr.pipe(function() {
                                return div.slideUp(self.options.speed);
                            });
                        });
                    }).resolve();
            return udfd;
        }

in “reload” I need to start “load” sequence after “unload” sequence is completed, but it starts right after first iteration of “unload” sequence element becomes hidden. Help me please, I’m stuck(

  • 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-05-26T02:53:19+00:00Added an answer on May 26, 2026 at 2:53 am

    Not tested but try this:

    unload: function() {
        var items = this.element.children('.nw-item').reverse();
        var self = this;
        var udfd = $.Deferred();
        var chain;
        $.each(items, function() {
            chain = udfd.pipe(function() {
                return $.Deferred(function(deferred) {
                    div.slideUp(self.options.speed, function() {
                        // callback function gets executed when slideUp is done
                        deferred.resolve();
                    });                
                }).promise();
            });
        });
        chain.done(function() {
            udfd.resolve();
        });
        return udfd.promise();
    }
    

    Since your jQuery.slideUp function is asynchronous BUT does not return an Deferred Object like e.g. jQuery.ajax you have to manually return a Deferred/promise. When your chain of piped functions is done it resolves the main Deferred. Don’t forget to return a promise for the main Deferred.

    Like I said, no guarantee but you could give it a try!

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

Sidebar

Related Questions

I'm stuck with this code, I'm getting this json formated data from the Youtube
I'm stuck with this. I'm self studying assenbler and translating some basics instructions. But
Trying to follow some basic examples and getting stuck by this code that is
I was reading the C++0x FAQ by Stroustrup and got stuck with this code.
I just started development for Android, and I am stuck with this code: public
Hi everyone im stuck with this code im practically new to php... what im
i am stuck by this code snippet that emulates server-client interaction,suppose that sockfd is
I'm stuck on this code and can't figure out where I need to go.
This code is just stuck in the Body it does exactly what I expect
I was following this tutorial, bit stuck here: This code doesn't compile, and the

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.