Skip to main content
Participant
September 30, 2011
Question

CFSelect Bind events (onBindError, why no onBindSuccess)

  • September 30, 2011
  • 4 replies
  • 2082 views

I'm working with using ajax and doing a bind with a CFSelect in order to dynamically populate it from a database.  The problem I'm having is it takes time to do this, so I need a way to show that the data is loading to the user.  I cannot find anyway to tell when a bind is completed though.  There is an onBindError event apparently, but no onBindSuccess.

Is this a foolish oversight on adobe's part, or is there some other method of being able to tell when a bind operation has succesfully completed?  Surely they anticipated such an obvious need for something like this rather than having forms just suddenly change while the user is in the middle of doing something in them.

    This topic has been closed for replies.

    4 replies

    WebolutionDesigns
    Known Participant
    October 3, 2011

    I am only assuming that you are utilizing a CFC to hit the DB and work with the bindings...Perhaps you could try verifying for the existence of the return from the cfc in a script/function? Then fire and event off of that? Never tried it...just a thought.

    Legend
    October 3, 2011

    I use jquery to do stuff like this which give me more control over the flow, including an onSuccess. While I'm a big fan of ColdFusion, I'm not a fan of ColdFusion's black box approach to ajax.

    BKBK
    Community Expert
    Community Expert
    October 1, 2011

    There is one good reason I can think of why the ColdFusion team hasn't given much weight to onBindSuccess. It isn't an urgent requirement for an asynchronous call.

    The first A in AJAX stands for asynchronous. For example, a bind may involve the client making an AJAX call to a function on the server.

    The universal understanding and agreement about asynchronous calls is that they are "fire-and-forget". The client makes the call, then forgets it and proceeds with other business, leaving it up to the server to decide when to respond. This programming paradigm has one implication. It is up to the client to include a signal in the request to ensure that the server's response will alert him that the bind process is complete.

    Inspiring
    September 30, 2011

    There are probably other ways to achieve your objective.  Are you talking about Related Selects or something similar?

    Participant
    September 30, 2011

    Yes it's a related select, one seelcts a location, the other populates with a list of employees at that location.

    I know I could do my own ajax code to acheieve what i want, but I figured coldfusion has the handy built in functions why not use them.  Seems silly that something as basic and an obvious need as a bind load completed event was not written.  At least I think it's obvious, unless you live in a world of instantaneous database queries and load times then you need some way of handling the load delay.  Without knowing when the load finishes you can't handle the load delay.

    I've tried using the OnChange even since the chance of the first item in the list being the same at two different locations is highly unlikely, but that did not fire when the selection changed to the first one in the new list.  I suppose I could set a timed event to go off ever second and look for differences in the list, but that seems like a kind of obsurd solution to this problem.

    I still just can't believe that they didn't think to include an OnBindSuccess event.

    Inspiring
    September 30, 2011

    Another approach is to push all the necessary data to the client on the initial page load.  It's old fashioned but works just as well now as it did when it was the only option available.

    There is more than one way to do this.  Here is one.  http://www.pathcom.com/~bracuk/code/RelatedSelects.htm