you seem to be trying to attach the observer before the dom has
loaded. So it won't have the element to attach the observer to. Here's
an option -
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:h="http://java.sun.com/jsf/html";>
    <h:head>
        <title>Facelet Title</title>
        <script src="javascripts/prototype.js" type="text/
javascript"></script>
        <script src="javascripts/scriptaculous.js" type="text/
javascript"></script>
        <script type="text/javascript" language="javascript">
           document.observe('dom:loaded',function(){
                 Event.observe('btn1','click', function() {
                    alert('Did you want to click ?');
                 });
                /* add any other code you'd want here */
            });

        </script>
    </h:head>
    <h:body>
        Hello World
        <h:form>
            <h:button id="btn1" value="Click Me"/>
        </h:form>
    </h:body>
</html>

On Jun 17, 2:12 pm, NewToProtoType <[email protected]> wrote:
> Hi
> I am trying to display a pop up using Event.observe method and I can't
> get it to work. Any help is appreciated. Please see my sample page and
> script.
>
> I am using FireFox 3.6, Red Hat Linux, NetBeans and GlassFish V3.
>
> <?xml version='1.0' encoding='UTF-8' ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";
>       xmlns:h="http://java.sun.com/jsf/html";>
>     <h:head>
>         <title>Facelet Title</title>
>
>         <script src="javascripts/prototype.js" type="text/
> javascript"></script>
>         <script src="javascripts/scriptaculous.js" type="text/
> javascript"></script>
>
>         <script type="text/javascript" language="javascript">
>
>             Event.observe('btn1','click', function() {
>                 alert('Did you want to click ?');
>             });
>
>         </script>
>     </h:head>
>     <h:body>
>         Hello World
>         <h:form>
>
>             <h:button id="btn1" value="Click Me"/>
>
>         </h:form>
>     </h:body>
> </html>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.

Reply via email to