rsijaya
rsijaya

Reputation: 169

Grails: How to put javascript/ajax in taglib?

How to put javascript code in grails taglib? example I have grails taglib :

def ajaxSelect = { attrs ->
        out << """
            <script type="text/javascript"> 
        $(document).ready(function(){
        $.ajax({
                ....
        });
        });         
        </script>
        """

I get the following error :

either escape a literal dollar sign "\$5" or bracket the value expression "${5}"

What i miss?

Upvotes: 4

Views: 1688

Answers (1)

eugene82
eugene82

Reputation: 8822

So, escape it:) Add a \ before every $ in your multiline string.

Upvotes: 5

Related Questions