Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

[Grails] Add form elements with javascript

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Jack Rackham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You're missing a comma after the action.
 
Jack Rackham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic