On Tue, Jan 17, 2006 at 08:30:52AM -0700, Gregory Hill wrote:
> <script type="text/javascript">
> Event.observe('element_id', 'click', function (e) { Ajax.Updater();
> Event.stop(e); return false; });
> </script>
>
Geeze, I can't even get something simple working.
I can get the example for Event.observe to work without any problem,
but I can't see to assign by id.
This example works:
<script>
Event.observe(window, 'load', showMessage, false);
function showMessage() {
alert('Page loaded.');
}
</script>
This generates "element has no properties" in prototype.js in
line 1479
<script type="text/javascript">
function sayHello() {
alert( 'Hello Message' );
}
Event.observe( 'updater1', 'click', sayHello, false);
</script>
And the element with that id is:
<a href="http://localhost:3000/workshop/classes?o=name&p=7"
id="updater1">Workshop</a>
Here's the try with Ajax.Updater:
<script type="text/javascript">
Event.observe(
'updater6',
'click',
function(e) {
Ajax.Updater('updater6',
'http://localhost:3000/workshop/classes?o=class_time&p=7', { method: 'get',
requestHeaders: ['X-Ajax-Updater', 'ajax_table'] });
Event.stop(e);
return false;
},
false
);
Event.observe(
'updater7',
'click',
function(e) {
Ajax.Updater('updater7',
'http://localhost:3000/workshop/classes?o=class_time&p=7', { method: 'get',
requestHeaders: ['X-Ajax-Updater', 'ajax_table'] });
Event.stop(e);
return false;
},
false
);
</script>
Then the links look like this:
<th id="updater6">
<a href="http://localhost:3000/workshop/classes?o=class_time&p=4"
id="updater7">
Date and Time
</a>
</th>
> And drop your inline event handlers. It's a pain dealing with stopping
> events on inline handlers.
The problem with prototype and all these nice javascript libraries is
that it makes it easy for someone like me to use them. ;)
I didn't realize that the inline handlers were any different than what
you have above. I thought they all assigned to the same event.
--
Bill Moseley
[EMAIL PROTECTED]
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs