开发者

Grails and Javascript

开发者 https://www.devze.com 2023-03-26 00:39 出处:网络
I would like to know how to use tinybox in my Grails app. I\'ve tried this so far (placed it inside the head tags):

I would like to know how to use tinybox in my Grails app. I've tried this so far (placed it inside the head tags):

&开发者_JAVA百科lt;g:javascript library="TinyBox/tinybox"/>   

<g:javascript>

    function errorResponse(){
        var b = ["Oh com'on!Say it!",
                "At least say a word!",
                "Don't be mean, say something. :)",
                "I'll be sa sad."];
        var a = Math.floor(Math.random()*3);            
        //alert(b[a]);
        TINY.box.show(b[a],0,0,0,0,3);
    }
</g:javascript> 

And I called it somewhere inside my form:

...
<g:submitToRemote update="comments" url="[controller:'sushiTrail',action:'save']" value="Send" onFailure="errorResponse();" onSuccess=" comment.value='';"></g:submitToRemote>
...

I'm new to both grails and Javascript. Tinybox is supposed to load when validation fails. I've tried a simple alert() and it worked, and I seriously think there is something wrong with the way I call stuff. I followed the tinybox demo here, but I still can't get it going even though view source seems to be correct. Can someone enlighten me?

Note: there was no error. The tinybox just didn't appear. :(


The <g:javascript> tag only accepts values "prototype", "scriptaculous", "yahoo" or "dojo" for the library attribute, so the following won't work:

<g:javascript library="TinyBox/tinybox"/>   

Add the tinybox JavaScript files to the Grails application's web-app/js directory and use one of the following instead to import it:

<g:javascript src="path/to/tinybox.js" />

or

<script type='text/javascript' src="path/to/tinybox.js"></script>
0

精彩评论

暂无评论...
验证码 换一张
取 消