Ok, sounds like you've got a little js on-demand action going on. I use the
model a ton in my widget framework. The first thing I think you need to take
care of is implementing a custom event model on the client (not for just DOM
events, but allowing your classes to fire and subscribe to custom events as
needed).

Check out my EventPublisher class, which is a very lightweight, easy to use
tool for this. Link to code here from my original on this list a year ago:
http://wrath.rubyonrails.org/pipermail/rails-spinoffs/2006-February/002875.htmland
link to short usage explanation here:
http://lists.rubyonrails.org/pipermail/rails-spinoffs/2006-March/002885.html

Then, I'd suggest just creating a globally accessible instance of the above
class to act as an event dispatcher...

var globalEventDispatcher = new EventPublisher();

Then you can do something like this at the end of your PHP generated
function...

globalEventDispatcher.fireEvent( "phpGeneratedJSExecuted", {someProperty:
"someValue"} );

Then, in order to make your other functions execute after that php generated
one, attach them to the event dispatcher (using the same event name)...

globalEventDispatcher.attachEventHandler( "phpGeneratedJSExecuted",
yourHandler );

Where "yourHandler" is a reference to a function that looks something like
this:

function someFunction(args)
{
// make sure this is the correct event for this function
if (args.someProperty == "someValue")
doSomething();
}

On 2/1/07, Matt <[EMAIL PROTECTED]> wrote:
>
>
> On Feb 1, 12:28 pm, "Ryan Gahl" <[EMAIL PROTECTED]> wrote:
> > Matt, in any event based language/system... it is considered best
> practice
> > that if any 2 event handlers rely on the order of their execution, then
> they
> > should be combined into a single handler (or one method calls the
> other).
> > ...
>
> I understand your point, and I appreciate the comments.  I guess
> handlers don't really have to execute in order, but I assumed it would
> make sense if they did (especially since that's the way FF does it :D)
>
> Anyway, of course, in most cases, I could wrap my functions into one,
> but my problem is that I don't have access to one of the
> Event.observer registrations since it's been wrapped up in output
> produced by PHP.  My functions are dependent on that handler to be
> called first.  And I don't want to change the PHP because the PHP
> classes are suppose to abstract the implementation of the tool, and
> having to register a function outside the PHP that was created inside
> the PHP breaks that abstraction.
>
> Right now, I'm just setting a timeout on a function (that calls my
> functions in order) if the element that I'm dependent on doesn't exist
> yet.  It will continue to set an additional timeout every time it sees
> the element doesn't exist.  It seems hackish though.  But right now
> that's the only way that seems feasible / makes me happy :P  Works
> like a charm though, so maybe I'll just stick with that.
>
> Again, if you have a suggestion, I'd appreciate it.
>
> Thanks,
> Matt
>
>
> >
>


-- 
Ryan Gahl
Application Development Consultant
Athena Group, Inc.
Inquire: 1-920-955-1457
Blog: http://www.someElement.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to