The example below works fine as expected until I add <form> tag around
the input tag.
<html>
<head>
<title> Test Page </title>
<script src="prototype.js"></script>
<script>
Event.observe(window, ''load'', page_loaded, false);
function page_loaded(evt) {
Event.observe(''child1'', ''click'',
item_clicked, false);
Event.observe(''child2'', ''click'',
item_clicked, false);
Event.observe(''child3'', ''click'',
item_clicked, false);
}
function item_clicked(evt){
var child = Event.element(evt);
var ans = confirm(''The child node with id='' + child.id
+ '' was
clicked. Do you want to stop click for this.'');
if (ans == true) {
Event.stopObserving(child.id,''click'',item_clicked); //
avoid another call related to ''parent_node'' itself
}else {
Event.stop(evt); //avoid another call related to
''parent_node'' itself
}
}
</script>
</head>
<body>
<div id="parent_node">
<input id="child1" type="image"
src="../web/images/add_button.gif"
name="org.apache.struts.taglib.html.SUBMIT"/>
<div id="child2">Second</div>
<div id="child3">Third</div>
</div>
</body>
</html>
I wonder why it is not working anymore when <form> tag is included.
How to make Event work inside <form> tag?
<form>
<div id="parent_node">
<input id="child1" type="image"
src="../web/images/add_button.gif"
name="org.apache.struts.taglib.html.SUBMIT"/>
<div id="child2">Second</div>
<div id="child3">Third</div>
</div>
</form>
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---