作为 .click 的一部分,通过其 API 调用 JQUERY 插件(超大)的函数 [英] Calling function of a JQUERY Plugin ( supersized ) via its API as part of a .click

查看:23
本文介绍了作为 .click 的一部分,通过其 API 调用 JQUERY 插件(超大)的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我远不精通 JS,所以请原谅任何明显的疏忽.我一直在尝试使用超大背景幻灯片插件的 API 作为常规 (element).click(function() 的一部分.

I'm far from proficient in JS, so please forgive any obvious oversights. I've been trying to use the API of the Supersized background slideshow plugin as part of a regular (element).click(function().

API 记录在此处,包括.对我的问题似乎很重要的部分:

The API is documented here incl. the part seemingly important for my problem:

api.goTo( targetSlide ) 触发转换到目标幻灯片编号.

api.goTo( targetSlide ) Triggers transition to target slide number.

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

基于此,我将拍摄以下代码,以便有一个带有按钮"类加载幻灯片编号 5 的 div:

Based on this, I would shoot for the following code in order to have a div with class "button" load slide number 5:

$(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. Still, I'm including it here as background info.

任何帮助将不胜感激.

推荐答案

我偶然发现了同样的问题 - 然后意识到我已经下载了 SuperSized 版本 3.1.3(来自遗留版本的最新版本此处),完全忽略了当前的下载链接版本(截至今天为 3.2.4).但是,API 调用仅从 3.2 开始支持 - 那么您是否遇到了同样的问题?

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). However, the API calls are only supported from 3.2 upward - so maybe you are experiencing the same problem?

下载最新版本后,您发布的代码在我这边工作得很好.

After downloading the latest version, the very same code you posted worked just fine on my end.

这篇关于作为 .click 的一部分,通过其 API 调用 JQUERY 插件(超大)的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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