I have a chatbox. User types message into chatbox and presses submit button. Message is posted to database, and then Jquery polls database for messages. it's basically realtime chat.
My problem is that when a user hits submit, the chatbox does not clear. I am using AJAX forms module so the page does not refresh, so now the user has to clear the chatbox before they are able to enter a new message.
I am trying to figure out how to do this automatically after submit.
I thought #ahah could do it. I have wrapped the chatbox in a div element and on event, I replace with "" but now, I erase the whole chatbox instead of the chatbox text contents.
What is the best way to go about this? thanks a ton!
Comments
Nothing?
I had hoped this was an easy one..
Responding to my own question.
I go through the drupal forum and try to answer questions when I can. Most times, it appears that the questions are above my head, OR will take hours to figure out. I don't want to be a help vampire, but I'm just not that progressed to whip out 10 answers in 10 minutes... Nevets, has it, I don't.
that all said, I do try to post answers to my own questions because I figure if they don't get answered and I answer them, someone will likle have the same question.
Solution: I was not able to solve this using the ajax form module. Instead, I used my own jquery.
I started off with grabbing the Jquery FORM plugin. http://jquery.malsup.com/form/. I installed it into my Drupal system using the Jquery Plugin Handler module http://drupal.org/project/jqp. The plugin uses aspects of jquerty 1.3 so I also had to add Jquery Update 6.2 alpha. http://drupal.org/project/jquery_update
Once those are all installed, you load the Form Plugin (see docs) and then simply Ajaxify your form and subsequently clear it using the following jquery.
Wow. Was that easy. Perfect for my live chat application. Hope this helps someone. For some reason clearing an ajax form with jquery alone isn't the easiest thing. Form Plugin really helps. Ajaxify the form, and do a lot more with only a few lines of jquery.
How To!
Thanks for replying to your own question:) and thats exactly I need to fix but I'm a beginner in this stuff so I need little guidance from you. I've installed the JQP module and the jquery form plugin is just a text file how I'll install it in the drupal. can you please explain the steps in installing and loading the plugin and where do I enter your code? I really appreciate it.