• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 67596
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: 67596
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: 67596
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.
reply
    Bookmark Topic Watch Topic
  • New Topic