jQuery-设置插件默认值? [英] jquery - setting plugin defaults?

查看:114
本文介绍了jQuery-设置插件默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与别人的插件而不是我自己的插件聊天.我想做到这一点而无需触碰他们的代码(我想在一个单独的文件中完成).

I'm talking with someone else's plugin, not my own. I'd like to do this without touching their code (I'd like to do it in a separate file).

我认为有办法做到这一点,

I thought there was a way to do that, something like:

$.defaults.pluginname还是其他?

$.defaults.pluginname or something?

推荐答案

这完全取决于插件及其编写方式.对于较大的插件,是通常(通常是)支持,但绝对不能保证,并且插件的编码方式也有所不同...因为有一个十二种不同的基本方法.

This completely depends on the plugin and how it was written. For the larger ones yes this is typically supported (most of the time) but it's definitely not guaranteed and definitely varies in how they coded the plugin...since there are a dozen different fundamental ways to do it.

如果您发布了要修改的实际插件,我们可以告诉您最好的方法,但是不能保证您无需编辑代码即可做到这一点.

If you posted the actual plugin you want to modify we can tell you the best approach do it, but there's no guarantee you can do this without editing its code.

编辑:由于您使用的是 colorbox插件,因此可以使用暴露 settings对象以在设置默认值之前像这样呼叫.colorbox():

since you're using the colorbox plugin you can use the exposed settings object to set defaults before calling .colorbox(), like this:

$.colorbox.settings.opacity = 0.5; //background opacity for example

颜色框选项中的任何一个都可以通过这种方式设置.

Any of the colorbox options are settable this way.

这篇关于jQuery-设置插件默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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