在Grails资源插件中使用JQuery插件 [英] using JQuery plugins with Grails resources plugin

查看:130
本文介绍了在Grails资源插件中使用JQuery插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Grails资源插件的应用程序中包含诸如 FancyBox 之类的JQuery插件的最佳/最简单的方法是什么?

FancyBox插件包含.js,.css和图片文件。在这个插件中,假设图像和.css文件在同一个目录中



一般情况下,.js文件也可以引用图像, .css文件。在Grails应用程序中,我想将.css文件放在 / web-app / css / fancybox 下, / web下的.js文件-app / js / fancybox 以及 / web-app / images / fancybox 下的图片文件,并为它们声明资源模块

  modules = {
fancybox {
dependsOn'jquery'

resource'/ js /fancybox/foo.js'
资源'/css/fancybox/bar.css'
资源'/images/fancybox/bg.png'
//等等
}
}

但我希望这会打破插件中文件的引用。是否有一系列步骤可以为JQuery插件创建一个模块,使我可以将资源存储在适当的位置(例如,在 web-app / css / pluginName 下的插件CSS资源) code>),那不需要我手动更新插件中的路径?

解决方案

我认为回答你最后的问题可能不是。但是如何释放一个grails插件呢?即使插件与同一文件夹中的所有文件有点混乱,这也可以为社区提供服务并保持应用程序的清洁。



更新



我只是在做一些相关的工作,并意识到您应该可以随意分发这些文件,因为在运行时,Resources插件会将所有文件放在 < app> / static /



但我仍然认为插件是个好主意。

What's the best/easiest way to include a JQuery plugin like FancyBox in an app that uses the Grails resources plugin?

The FancyBox plugin includes .js, .css, and image files. In this plugin, it's assumed that the image and .css files are in the same directory

In general, it's also possible that the .js files have references to the image and .css files. In a Grails app, I would like to put the .css files under /web-app/css/fancybox, the .js files under /web-app/js/fancybox and the image files under /web-app/images/fancybox, and declare a resources module for them

modules = {
    fancybox {
        dependsOn 'jquery'

        resource '/js/fancybox/foo.js'
        resource '/css/fancybox/bar.css'
        resource '/images/fancybox/bg.png'
        // etc.
    }
}

But I expect this will break the references among the files in the plugin. Is there a series of steps I can follow to create a module for a JQuery plugin, that allows me to store the resources in an appropriate place (e.g. plugin CSS resources under web-app/css/pluginName), that doesn't require me to manually update the paths in the plugin?

解决方案

I think the answer to your last question is probably no. But how about releasing a grails plug in for this? That would service the community and keep your app clean, even if the plugin was a bit messy with all the files in the same folder.

UPDATE

I was just doing some related work and realized that you should be OK to distribute the files as you want because at run time, the Resources plugin will put all the files in <app>/static/.

But I still think a plugin would be a good idea.

这篇关于在Grails资源插件中使用JQuery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆