On Tue, Jan 17, 2006 at 03:16:04PM -0700, Gregory Hill wrote:
> Is the element farther down the page than the javascript? HTML is
> rendered in the order it is output. If you try to get an element that
> has yet to be rendered, it does not exist.
No comment. ;)
It was the "new" that I had left off, too.
But I think I have another problem. The link I click on happens to
be included in the HTML returned from the Ajax request.
I expect that's not going to work very well, unless I reset the event
handler after the ajax completes. Plus, it seems to add the new
content instead of replacing the old content. Very ugly.
So I went back to the inline onclick handlers. Looks like I'm going
to have skip using an onclick on the link's enclosing <td> or <tr>.
In your examples you had function(e) {} in the onclick handler:
<th onclick="function(e) { new Ajax.Updater('tableTable', 'http://url?sort=foo'
); Event.stop(e); return false; }">
How does that function get called? Needs "new" in front, right?
I thought perhaps this would also work, but nothing happens:
onclick="( function(e) { new Ajax.Updater(), .. })()";
Anyway, I can't seem to get Event.stop(e) to work on the onclick
handler, only the last of these is working.
"new function(e) {new Ajax.Updater('$table_id', '$link', { method: 'get',
requestHeaders: ['X-Ajax-Updater', 'ajax_table'] } ); Event.stop(e); return
false;}"
"new function(e) {new Ajax.Updater('$table_id', '$link', { method: 'get',
requestHeaders: ['X-Ajax-Updater', 'ajax_table'] } ); Event.stop(e); return
false;}; return false;"
"new Ajax.Updater('$table_id', '$link', { method: 'get', requestHeaders:
['X-Ajax-Updater', 'ajax_table'] } ); Event.stop(e); return false;"
"new Ajax.Updater('$table_id', '$link', { method: 'get', requestHeaders:
['X-Ajax-Updater', 'ajax_table'] } ); return false;"
Seems like whenever I use Event.stop(e) then both the ajax request and
the normal href http requests happen. So it seems like Event.stop(e)
must be causing the onclick handler to return true, which then causes the href
to fire.
This stuff can eat time!
--
Bill Moseley
[EMAIL PROTECTED]
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs