junaidp
junaidp

Reputation: 11201

how to access my groovy/ grails values from Javascript

I have an array in my grails class

class BootStrap {

  def init = { servletContext ->
    def myArray = ["Aug 2011","111.0"]
    new IndexValue (indexDate: new Date (),value: 100).save(flush:true)
    assert IndexValue.count()==1
  }

  def destroy = {
  }
}

Now in my javascript i have this value

var endDate = month + ' ' + endDate.getFullYear();

I just need to check if this endDate is the same as the date in my array above, if this date is there, just give an alert date is present

Upvotes: 1

Views: 1844

Answers (1)

Igor Artamonov
Igor Artamonov

Reputation: 35961

Pass it as javascript variables, when you're rendering gsp, like:

<g:javascript>
  window.month = ${month}
</g:javascript>

where month is your grails/gsp variable

Upvotes: 5

Related Questions