Account Options

  1. Sign in
Google Groups Home
« Groups Home
Approaching popup callback hell
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matt Wilson  
View profile  
 More options Aug 18 2009, 11:23 am
From: Matt Wilson <m...@tplus1.com>
Date: Tue, 18 Aug 2009 08:23:31 -0700 (PDT)
Local: Tues, Aug 18 2009 11:23 am
Subject: Approaching popup callback hell
I'm using a modal dialogs and I love them, but I haven't found a
really elegant way to handle actions in the dialog window that require
changes to the parent page.

Here's an example.  I have a monthly calendar page that lists employee
names on the days they are supposed to work.  Clicking on an employee
name opens a "shift detail" page in a modal dialog.

That shift detail page has more information like the specific tasks
planned for the day, the start time and stop time of the shift, etc.
From this shift detail screen, I can remove this particular employee
from the schedule by submitting an AJAX POST from this popup.

After I remove the employee, I need to update both the popup window
and the original page that hosted the link to the popup window.  Right
now I do this by adding a callback that fires when the AJAX POST
succeeds.  That callback then updates both pages.  The callback is
named "after_remove_employee".

This system gets really nasty when I use the "shift detail" popup on
different screens.  For example, in addition to the monthly view, I
also have a weekly view with more information.  So after an employee
is removed from the schedule on the weekly view, I need to do some
different things in the callback.

Right now, the way I handle this is that I define the same callback
twice.  I define "var after_remove_employee = function (data) {...} on
the weekly view to do what it needs there, and then I define it
differently on the monthly view.

I've simplified the problem to help explain it.  In reality, I have
lots of different popups on lots of different pages, and in each
popup, there are many different possible actions.

I'm sure I'm not the only one that's been in this scenario.  What is
an elegant solution?

I'm thinking about using custom events.  So, the callback after a
successful AJAX POST would just fire an "employee removed" event, and
everybody subscribed would get a reference to the event object and do
whatever they want.

However, I've never used JS events before, and I don't know if this is
even possible.

Please, any feedback is welcome.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »