Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Executing a jquery function on a condition

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I have a condition in my page like

<g:if test="${session.user}">

I need to execute a jQuery function which will show a dialog or a message saying User exists or something like that. How can I do that ?

thanks

- Harjit
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what the "g" custom tag library is, but whatever it is that's a server-side construct that's evaluated long before the page gets to the client where JavaScript (and jQuery) is evaluated.

You'll need to explain what and when you want things to happen so we can figure out how to implement it.

If just want the jQuery function to execute on page load, you can use the if construct to include or exclude the code in the markup. If you want the function to execute based upon client-side mechanisms (such as events), server-side conditionals aren;t going to be of any help.
 
Harjit Singh
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I have no idea what the "g" custom tag library is, but whatever it is that's a server-side construct that's evaluated long before the page gets to the client where JavaScript (and jQuery) is evaluated.

You'll need to explain what and when you want things to happen so we can figure out how to implement it.

If just want the jQuery function to execute on page load, you can use the if construct to include or exclude the code in the markup. If you want the function to execute based upon client-side mechanisms (such as events), server-side conditionals aren;t going to be of any help.




g is a grails tag and here I'm checking for a condition whether a user is present in the session. What I need to do is
when I have a user in the session . I need to display a popup or show a message saying that user is linked.

- Harjit
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please answer the questions. When? At page load?
 
Harjit Singh
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please answer the questions. When? At page load?




Yes.....
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then simply include the script or not using the "if" logic.
 
Arthur, where are your pants? Check under this tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic