If you change your onSubmit to "console.log(comment); return false" what
do you get?
Also, I wouldn't use the inline event handler. I'd add this line to
your initialize function: (make sure you wrap form inside of $() first)
this.form.observe('submit', this.post.bind(this));
Then in your post function, have it accept an event parameter and add
event.stop() in it (to mimic your "return false" that you have in your
inline handler)
Chris wrote:
> Dear all,
>
> I have decided to use the new Class function in the newest release of
> Prototype (1.6) and re-write a function I currently have, reason been
> for the simplicity to update it and to learn something new.
>
> I wrote this bit of code:
>
> var Comments = Class.create({
> initialize: function(form) {
> username = 'cmellor';
> this.form = form
> },
> // Post a comment
> post: function() {
> if(Spry.Widget.Form.validate(this.form) == true) {
> new Ajax.Updater('user_comments', 'configs/ajax_functions.php?
> profile_comment=post', {
> insertion: Insertion.Top,
> parameters: {
> user: username,
> comment: $F('comment')
> },
> onLoading: function() {
> $('comment_button').disable().value = 'Adding Comment';
> $('comment').clear().disable()
> },
> onSuccess: function() {
> $('comment_button').value = 'Comment Posted';
> }
> });
> }
> }
> });
>
> var comment = new Comments('post-comment');
>
> I use the code in a form tag using an onsubmit behaviour, like so:
>
> <form id="post-comment" onsubmit="comment.post(); return false">
>
> Something isn't right about this, because I submit the form, it
> refreshes and Firebug gives me the error "comment.post is not a
> function"
>
> Can somebody perhaps point out to me what I am doing wrong, any help
> would be appreciated :)
>
> Thank you,
>
> - Chris.
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---