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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:33:10+00:00 2026-06-13T04:33:10+00:00

I’m trying to make a crossFadeVisible bindingHandler. The main idea is that when we

  • 0

I’m trying to make a crossFadeVisible bindingHandler. The main idea is that when we set a value, I’d like it to fade in. If we clear the value (ie. set to null), I’d like to have it fade out, and if we change the value, I’d like to have it fade out on the old value, and fade in on the new value.

I’ve been fighting the better part of the afternoon on this, so I’m not entirely sure it’s possible.

I decided I’d follow what I saw others doing, and create a jsfiddle for this (http://jsfiddle.net/jrstarke/4DTFq/20/).

Initially the value is undefined, but if you hit Set, we set the value to 1, and add some new buttons. If you now clear the value, it goes away as expected, and setting it again works fine. If you hit increment, everything works as expected.

And now the part I can’t explain. If with ‘2’ showing, you hit increment, nothing happens. Clear, the buttons go away (since we’ve now cleared the original value). But the display value stays the same.

What seems to have happened, that I can’t explain, is when we call the value.displayed(value()) to set the new display value to the current value, it causes the update method to be called again immediately (?) at which point we run through the method completely, and it updates as expected, but it appears we have unbound the value from changes, as this update method never gets called again.

Anyone know how to fix this, or if what I’m trying to do is possible?

  • 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-13T04:33:11+00:00Added an answer on June 13, 2026 at 4:33 am

    The problem is that the update code for your handler is never called after the first fadeOut. The reason is that the dependency tracking code doesn’t detect that your binding depends on value because it is never actually read. So when the value actually does get updated, the binding is never retriggered.

    Why that happens is because the postFade code doesn’t get called as the binding is being updated. It actually gets called afterwards when the fadeOut completes. It updates when it is initially updated because the postFade function was called when value.displayed was falsy.

    A simple way to fix this would be to read value somewhere when the update code is called. You don’t necessarily have to do anything with the value, just that you attempt to read it.

    update: function(element, valueAccessor) {
        var value = valueAccessor();
    
        var postFade = function() {
            // postFade depends on `value`
            value.displayed(value());
            if (value.displayed()) $(element).fadeIn('fast');
        }
    
        if (value.displayed()) {
            // postFade is invoked later after the fade out
            $(element).fadeOut('fast', postFade);
            // dependent on `value.displayed`
    
            // get the value so the dependency tracking code
            // detects that the binding depends on it
            value();
        }
        else {
            // postFade is invoked immediately
            postFade();
            // dependent on `value.displayed` and `value`
        }
    }
    
    • 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’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.