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
-~----------~----~----~----~------~----~------~--~---