grails asset pipeline plugin

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

grails asset pipeline plugin

nishtha

Hey,
I have read the documentation of Grails asset pipeline plugin so I started implementing it in a sample grails project built in 2.2.3 .I installed the asset pipeline plugin version 1.7.1. My requirement is to include the jquery.ui.min.js in my gsp file so I included by using the tag . Also, in my Config.groovy, I have made the following entry grails.assets.bundle=true. The problem which I am facing is that I'm unable to access the jquery.ui.min.js in my gsp file. Pease tell me what am I missing and how should I proceed with it as I could not get any valid solutions for my query??
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

Roberto Guerra
Can you paste the code that is including jquery in your gsp?

It might not be where you think it is. A working example:

1. Place jquery under grails-app/assets/javascript/vendor
2. Import it directly to your gsp: <asset:javascript src='vendor/jquery.js'/>. Notice you do not need to specify 'javascript' in the tag because the asset pipeline will naturally omit the name of the directory under 'assets'. 
3. You can also import it via the application.js: //=require 'vendor/jquery' . Then you just need to import application.js in your gsp: <asset:javascript src='application.js'/>

Here are some examples from one of our projects:

application.js:

//=require jquery/jquery
//=require underscore/underscore
//=require vendor/underscore.string
//=require isotope.pkgd
//=require backbone/backbone
//=require backbone.babysitter/lib/backbone.babysitter
//=require marionette/lib/backbone.marionette
//=require backbone.wreqr/lib/backbone.wreqr
//=require handlebars-runtime
//=require q/q
//=require_tree .

Q.stopUnhandledRejectionTracking()
Spantree.SearchUiApp.start();




the gsp:

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Search UI</title>
    <meta name="layout" content="main"/>

</head>

<body>
    <div id='header'></div>

    <section>
        <div id="container" class="container"></div>
    </section>

    <div id="footer"></div>

    <asset:javascript src="app/FilterCodec.js" />
    <asset:javascript src="lib/ElasticsearchRepository.js" />
    <asset:javascript src="application.js" />
</body>
</html>






On Thu, Mar 20, 2014 at 4:53 AM, nishtha <[hidden email]> wrote:

Hey,
I have read the documentation of Grails asset pipeline plugin so I started
implementing it in a sample grails project built in 2.2.3 .I installed the
asset pipeline plugin version 1.7.1. My requirement is to include the
jquery.ui.min.js in my gsp file so I included by using the tag . Also, in my
Config.groovy, I have made the following entry grails.assets.bundle=true.
The problem which I am facing is that I'm unable to access the
jquery.ui.min.js in my gsp file. Pease tell me what am I missing and how
should I proceed with it as I could not get any valid solutions for my
query??



--
View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Color me impractical but I’d rather be able to look at myself in the mirror than be rich.
-Evan Light
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

nishtha
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
   

    <asset:javascript src="jquery-ui.min.js"/>

</head>
<body>
<form name="newForm" id="newForm">
<label>This is your new form:</label>
<input type="button" value="OK" id="saveForm"/>
</form>


<script> $("#saveForm").on('click',function(){ var url="${createLink(controller:'sampleTest',action:'showData')}"; var data="Anonymous" jQuery.ajax({ type : 'POST', url : url, data : data success : function(response, textStatus) { alert(); } }); }); </script></body>
</html>
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

Roberto Guerra
In reply to this post by Roberto Guerra
Make sure jquery-ui.min.js is under grails-app/assets/javascripts.


On Thu, Mar 20, 2014 at 5:54 AM, nishtha <[hidden email]> wrote:
Hey great thanks for your valuable reply. Here is my gsp code. Please have a
look.

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>


    <asset:javascript src="jquery-ui.min.js"/>

</head>
<body>
<form name="newForm" id="newForm">
<label>This is your new form:</label>
<input type="button" value="OK" id="saveForm"/>
</form>



</body>
</html>



--
View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655260.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Color me impractical but I’d rather be able to look at myself in the mirror than be rich.
-Evan Light
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

nishtha
Hey, my jquery-ui.min.js is under grails-app/assets/javascripts only. Infact i've put css and image files within stylesheets and images respectively. But I really don't understand why the jQuery code is not working in the gsp??? Please provide some more useful information regarding this, would really be helpful for me.
Thanks,
Nishtha
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

Roberto Guerra
In reply to this post by Roberto Guerra
Are you getting any errors?


On Thu, Mar 20, 2014 at 6:26 AM, nishtha <[hidden email]> wrote:
Hey, my jquery-ui.min.js is under grails-app/assets/javascripts only. Infact
i've put css and image files within stylesheets and images respectively. But
I really don't understand why the jQuery code is not working in the gsp???
Please provide some more useful information regarding this, would really be
helpful for me.
Thanks,
Nishtha



--
View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655263.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Color me impractical but I’d rather be able to look at myself in the mirror than be rich.
-Evan Light
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

nishtha
Yes, as you can see in my gsp ,I have written the jQuery code to submit the form so I'm unable to submit my form and on the browser i get this error in the console:
Uncaught ReferenceError: jQuery is not defined
and this error obviously comes when jQuery-ui.min.js is not included in the gsp page. Please help with the issue.
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

netwiser
Your code did not declare the dependency of JQuery nor import it by <asset:javascript src="jquery"/>, find where is your jquery.min.js or you can link it from Google CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

> Date: Thu, 20 Mar 2014 06:16:25 -0700

> From: [hidden email]
> To: [hidden email]
> Subject: [grails-user] Re: grails asset pipeline plugin
>
> Yes, as you can see in my gsp ,I have written the jQuery code to submit the
> form so I'm unable to submit my form and on the browser i get this error in
> the console:
> Uncaught ReferenceError: jQuery is not defined
> and this error obviously comes when jQuery-ui.min.js is not included in the
> gsp page. Please help with the issue.
> Thanks
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655266.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

Roberto Guerra
Oh, yeah, jquery-ui needs jquery. You need to also include jquery. See James' comment.


On Thu, Mar 20, 2014 at 7:25 AM, James Zhang <[hidden email]> wrote:
Your code did not declare the dependency of JQuery nor import it by <asset:javascript src="jquery"/>, find where is your jquery.min.js or you can link it from Google CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

> Date: Thu, 20 Mar 2014 06:16:25 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: [grails-user] Re: grails asset pipeline plugin

>
> Yes, as you can see in my gsp ,I have written the jQuery code to submit the
> form so I'm unable to submit my form and on the browser i get this error in
> the console:
> Uncaught ReferenceError: jQuery is not defined
> and this error obviously comes when jQuery-ui.min.js is not included in the
> gsp page. Please help with the issue.
> Thanks
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655266.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>



--
Color me impractical but I’d rather be able to look at myself in the mirror than be rich.
-Evan Light
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

nishtha
In reply to this post by nishtha
Hey!!!! the code ran perfectly.. I made a stupid mistake..  Great thanks for your quick response. :D :D
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

nishtha
Hii,
I faced one more problem with images. I put all the images inside assets/images folder and in the gsp, I included images like this:

<asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>.
Since I have too many images, I wanted to ask for other images what should be the value of rel field here???

Thanks in advance :) :)
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

netwiser
<asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/> is for favicon purpose, you should use
<asset:image src="logo.png" width="200" height="200"/> to include your image

> Date: Fri, 21 Mar 2014 06:18:01 -0700

> From: [hidden email]
> To: [hidden email]
> Subject: [grails-user] Re: grails asset pipeline plugin
>
> Hii,
> I faced one more problem with images. I put all the images inside
> assets/images folder and in the gsp, I included images like this:
>
> <asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>.
> Since I have too many images, I wanted to ask for other images what should
> be the value of rel field here???
>
> Thanks in advance :) :)
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655313.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
Reply | Threaded
Open this post in threaded view
|

Re: grails asset pipeline plugin

David Estes
Exactly,
for more information please refer to the linking section of the docs:



On Mar 21, 2014, at 9:34 AM, James Zhang <[hidden email]> wrote:

<asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/> is for favicon purpose, you should use 
<asset:image src="logo.png" width="200" height="200"/> to include your image

> Date: Fri, 21 Mar 2014 06:18:01 -0700

> From: [hidden email]
> To: [hidden email]
> Subject: [grails-user] Re: grails asset pipeline plugin
> 
> Hii, 
> I faced one more problem with images. I put all the images inside
> assets/images folder and in the gsp, I included images like this:
> 
> <asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>.
> Since I have too many images, I wanted to ask for other images what should
> be the value of rel field here??? 
> 
> Thanks in advance :) :)
> 
> 
> 
> --
> View this message in context: http://grails.1312388.n4.nabble.com/grails-asset-pipeline-plugin-tp4655257p4655313.html
> Sent from the Grails - user mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email
> 
>