Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Grails and jQuery: how to get image to show that the user just typed in the URL to

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it worth it to use JQuery in your Grails app.

I still need to learn JQuery, but I would also have to learn Prototype if I used it.

Anyway, I want to show or hide some <div> based on if someone entered data in a property of my domain. So while editing that domain. Basically they are going to put a URL to an image, and I want to show that image on the page after they have entered it.

What is my best approach? OK, I changed the subject, let me update the subject line.

Thanks

Mark
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use jQuery for everything, as long as I get to make the decision.

Major untested pseudo code alert!!!



Also, moving this to the HTML / JavaScript forum.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Spritzler wrote:I still need to learn JQuery, but I would also have to learn Prototype if I used it.

"It" Grails, or "it" jQuery? I think Grails supports a couple of different JS libs, but I don't recall that jQuery was one of them. There's a plugin, though:

http://www.grails.org/plugin/jquery
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
Mark Spritzler wrote:I still need to learn JQuery, but I would also have to learn Prototype if I used it.

"It" Grails, or "it" jQuery? I think Grails supports a couple of different JS libs, but I don't recall that jQuery was one of them. There's a plugin, though:

http://www.grails.org/plugin/jquery


Well, it's support via the plugin. So if you install the plugin and make a couple of config mods, all the grails ajaxy tags will use jQuery instead of Prototype (the default). And that's really all the support is.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg Bolinger wrote:
David Newton wrote:
Mark Spritzler wrote:I still need to learn JQuery, but I would also have to learn Prototype if I used it.

"It" Grails, or "it" jQuery? I think Grails supports a couple of different JS libs, but I don't recall that jQuery was one of them. There's a plugin, though:

http://www.grails.org/plugin/jquery


Well, it's support via the plugin. So if you install the plugin and make a couple of config mods, all the grails ajaxy tags will use jQuery instead of Prototype (the default). And that's really all the support is.


So this takes it back to being a Grails question. The original question was about those config mods, what they mean, is it worth jumping through those hoops, or is it just 2 mods and then automatically you can use the jQuery type code you posted?

Mark
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used the jQuery plugin, but I'm not sure why it would need anything beyond the two things mentioned in the wiki article.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<g:javascript library="jquery" />

And in the Config.groovy file you add....

grails.views.javascript.library="jquery"

That's it. No hoops.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And technically, you only need the Config.groovy addition if you want the Grails remote taglibs to use jquery. Personally, I never use those tags, so all I need is to source in the jquery js file, which is what the <g:javascript /> is for.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg Bolinger wrote:And technically, you only need the Config.groovy addition if you want the Grails remote taglibs to use jquery. Personally, I never use those tags, so all I need is to source in the jquery js file, which is what the <g:javascript /> is for.


Thanks, and I assume if I just put that in my main.gsp layout, then all the pages will get that.

Things have been going really well too.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic