wood burning stoves 2.0*
The moose likes Groovy and the fly likes [Grails] Add form elements with javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "[Grails] Add form elements with javascript" Watch "[Grails] Add form elements with javascript" New topic
Author

[Grails] Add form elements with javascript

Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Hi everybody !

I'm new with Grails and I'm trying to add a field in a form. You'll see in the code below that I want to add a select field. However I don't succeed doing this. By despair I've tried doing this in plain javascript, but once again it didn't work (I can't even add a textfield !).
I've been consulting grails doc, but I've not found my answer. So do you have an idea how to do this ?

Here is my actual code (I've let js but I would rather do this in full Grails) :

addCompetences.gsp :




ProfilController.groovy (very *empty* for the moment, and wrong for the moment)



Thank you in advance.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6



You haven't specified the container that should hold the rendered HTML coming back from the server. Look at the update attribute:

http://www.grails.org/doc/latest/ref/Tags/remoteFunction.html


GenRocket - Experts at Building Test Data
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
I had tried with update, but Grails didn't like (not with the same as in the example ; and I've just tried now, It makes the same error). Look by yourself :

Error 500: Could not parse script [home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp]: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Servlet: grails
URI: /package/grails/profil/addCompetences.dispatch
Exception Message: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Caused by: Could not parse script [home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp]: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Class: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp
At Line: [86]


I've changed the structure of the page between times, but I had exactly the same error. In update, i've tried to put first the type of the container, the id of the element, and what is said as in example. Same error everytime.

So I've tried another way, more "conventionnal", but I still got an error. My js code is implemented, however it's not recognized ! Filezilla says that any method I try to call doesn't exist. I've done it with pure JS and jQuery, but anything I do, nothing happens. Even an alert with jQuery.

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6



You're missing a comma after the action.
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Thanks for your answer. I fixed this silly mistake but I still add an error. Finally a friend of mine did it by another way.
 
Don't get me started about those stupid light bulbs.
 
subject: [Grails] Add form elements with javascript