简体   繁体   English

作为 a.click 的一部分,通过其 API 调用 JQUERY 插件(超大)的 function

[英]Calling function of a JQUERY Plugin ( supersized ) via its API as part of a .click

I'm far from proficient in JS, so please forgive any obvious oversights.我远非精通JS,所以请原谅任何明显的疏忽。 I've been trying to use the API of the Supersized background slideshow plugin as part of a regular (element).click(function().我一直在尝试使用超大背景幻灯片插件的 API 作为常规 (element).click(function() 的一部分。

The API is documented here incl. API 记录在这里,包括。 the part seemingly important for my problem:对我的问题来说似乎很重要的部分:

api.goTo( targetSlide ) Triggers transition to target slide number. api.goTo(targetSlide) 触发转换到目标幻灯片编号。

//Goes to slide #5    $(element).click(function(){ api.goTo(5); });

Based on this, I would shoot for the following code in order to have a div with class "button" load slide number 5:基于此,我将拍摄以下代码,以便拥有一个带有 class“按钮”加载幻灯片编号 5 的 div:

$(document).ready(function(){

$(".button").click(function(){
  api.goTo(5);
});
});

This doesn't work - and the fact that the name of the plugin isn't anywhere in the code makes it obvious that the above code is lacking something.这是行不通的——而且插件的名称不在代码中的任何地方,这一事实使得上面的代码很明显缺少一些东西。 I just have no idea what.我只是不知道是什么。 I also tried placing it in various locations within the plugin's source and themes - but no luck so far.我还尝试将它放置在插件的源代码和主题中的不同位置 - 但到目前为止还没有运气。

This is a related post I've found. 这是我找到的相关帖子 However, the problem this person had was solved by modifying the plugin's theme in a manner that doesn't listen for the click event but rather is triggered by a function within the plugin.然而,这个人遇到的问题是通过修改插件的主题以不监听点击事件而是由插件内的 function 触发的方式解决的。 Still, I'm including it here as background info.尽管如此,我还是把它作为背景信息包括在这里。

Any help would be greatly appreciated.任何帮助将不胜感激。

I stumbled upon the same problem - and then realized that I had downloaded SuperSized version 3.1.3 (the latest from the legacy versions here ), and totally overlooked the download link for the current version (3.2.4 as of today).我偶然发现了同样的问题 - 然后意识到我已经下载了 SuperSized 版本 3.1.3(这里版本的最新版本),并且完全忽略了当前版本的下载链接(截至今天为 3.2.4)。 However, the API calls are only supported from 3.2 upward - so maybe you are experiencing the same problem?但是,API 调用仅支持从 3.2 开始 - 所以也许您遇到了同样的问题?

After downloading the latest version, the very same code you posted worked just fine on my end.下载最新版本后,您发布的相同代码对我来说效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM