|
|
Wrangling Javascript from PHP
I'm working on a bunch of classes in PHP that will render into HTML
a-la widgets. Part of this functionality is that I'd like to expose
Javascript in the classes and have each instance provide and/or
generate the needed code along with the HTML.
I've done a lot of server side generating and program state hackery
so...I'm not totally unfamiliar. I already have some javascript
functionality from the dojo toolkit, so I have a nice set of functions
to work with.
What I'd like is perhaps some input or a discussion on what could be
some best practices in achieving this with PHP.
For example,
Maybe I'll have to ask each object for the javascript code they want to
provide before rendering the final page and place it at the top of the
page?
The most complicated question is how will I expose all the events and
scenarios I want to have my classes generate code for? In PHP, what is
the best way to code a model to allow instantiated objects to perform a
"when this is clicked, do this with this object over here"? Smells
like an event-handling model, but that doesn't exist in PHP. And I
certainly don't want to have to go subclassing every widget I use for
each page! Hah.
Details, options and the implications of each one are really what I'd
like to explore...
Thanks to all who reply!
|
|
0
|
|
|
|
Reply
|
atrauzzi (20)
|
7/26/2006 2:32:42 PM |
|
Well to me if you are going to talk about event handling you need to
think Ajax. There are frameworks out there to do just what you are
talking about.
On 2006-07-26 15:32:42 +0100, "Omega" <atrauzzi@gmail.com> said:
> I'm working on a bunch of classes in PHP that will render into HTML
> a-la widgets. Part of this functionality is that I'd like to expose
> Javascript in the classes and have each instance provide and/or
> generate the needed code along with the HTML.
>
> I've done a lot of server side generating and program state hackery
> so...I'm not totally unfamiliar. I already have some javascript
> functionality from the dojo toolkit, so I have a nice set of functions
> to work with.
>
> What I'd like is perhaps some input or a discussion on what could be
> some best practices in achieving this with PHP.
>
> For example,
> Maybe I'll have to ask each object for the javascript code they want to
> provide before rendering the final page and place it at the top of the
> page?
> The most complicated question is how will I expose all the events and
> scenarios I want to have my classes generate code for? In PHP, what is
> the best way to code a model to allow instantiated objects to perform a
> "when this is clicked, do this with this object over here"? Smells
> like an event-handling model, but that doesn't exist in PHP. And I
> certainly don't want to have to go subclassing every widget I use for
> each page! Hah.
>
> Details, options and the implications of each one are really what I'd
> like to explore...
>
> Thanks to all who reply!
|
|
0
|
|
|
|
Reply
|
richard8978 (13)
|
7/26/2006 2:53:28 PM
|
|
That doesn't target the problem I have outlined.
What I'm after is a way of essentially coding PHP objects that then get
rendered into HTML AND Javascript.
The dojo toolkit I mentioned is one such framework but does not provide
the solution I am looking for. You may be better served by re-reading
my question again. Should you need any clarification, please ask as
I'm sure it would help others.
Richard Hulbert wrote:
> Well to me if you are going to talk about event handling you need to
> think Ajax. There are frameworks out there to do just what you are
> talking about.
>
>
> On 2006-07-26 15:32:42 +0100, "Omega" <atrauzzi@gmail.com> said:
>
> > I'm working on a bunch of classes in PHP that will render into HTML
> > a-la widgets. Part of this functionality is that I'd like to expose
> > Javascript in the classes and have each instance provide and/or
> > generate the needed code along with the HTML.
> >
> > I've done a lot of server side generating and program state hackery
> > so...I'm not totally unfamiliar. I already have some javascript
> > functionality from the dojo toolkit, so I have a nice set of functions
> > to work with.
> >
> > What I'd like is perhaps some input or a discussion on what could be
> > some best practices in achieving this with PHP.
> >
> > For example,
> > Maybe I'll have to ask each object for the javascript code they want to
> > provide before rendering the final page and place it at the top of the
> > page?
> > The most complicated question is how will I expose all the events and
> > scenarios I want to have my classes generate code for? In PHP, what is
> > the best way to code a model to allow instantiated objects to perform a
> > "when this is clicked, do this with this object over here"? Smells
> > like an event-handling model, but that doesn't exist in PHP. And I
> > certainly don't want to have to go subclassing every widget I use for
> > each page! Hah.
> >
> > Details, options and the implications of each one are really what I'd
> > like to explore...
> >
> > Thanks to all who reply!
|
|
0
|
|
|
|
Reply
|
atrauzzi (20)
|
7/26/2006 5:14:07 PM
|
|
|
2 Replies
30 Views
(page loaded in 0.046 seconds)
Similiar Articles:7/25/2012 12:52:10 AM
|
|
|
|
|
|
|
|
|