Hi,

I'm trying to embed some JavaScript in a component, and for the life of me
cannot get it to work. I can sort of understand why it's not working, I just
can't see what to do to fix it - if anyone can point me towards a
resolution, I'd be grateful - I'm currently playing with 5.0.15.

OK, this isn't my actual component, but it shows the problem... a simple
component that has a button that calls a javascript function.

TML
----
<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <input type="button" onclick="jsAlert()" value="JS Alert"/>
</div>

Java
----
import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.Environmental;

public class JSAlert
{
        private String alert = "function jsAlert() { alert(\"HELLO\"); }";

        @Environmental
        private RenderSupport renderSupport;

        @AfterRender
        public void afterRender() {
                renderSupport.addScript(alert);
        }
}

Basically, when you click the button, the browser says the JSAlert function
is not defined.

TIA

Lance

-- 
View this message in context: 
http://www.nabble.com/-T5--Idiot-Javascript-question-tp20699079p20699079.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to