在javascript函数中的jquery需要两次点击 [英] Jquery in javascript function require two clicks

查看:112
本文介绍了在javascript函数中的jquery需要两次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用jquery编写了一个simpe inline编辑。该插件工作得很好,但我有一个问题,当我在javascript函数内调用脚本时,它需要2次点击来激活插件。有没有人知道一种方法来解决这个问题..我只需要点击一下!提前致谢。

I wrote a simpe inline edit using jquery. The plugin work very well, but i have a problem when i call the script within a javascript function, it require 2 click to activate the plugin. Does anyone know a way to solve this issue.. i want it in one click! Thanks in advance.

<a onclick="update(1)"> Let's update<a/>

  function update(id)
  {
  $("#edit" + id).kb_edit();   
  }


推荐答案

需要你在里面设置的点击事件处理程序,那意味着它不会被设置,直到你运行 .kb_edit()

If the functionality in the plugin requires the click event handler that you're setting up inside, then that means it won't be set up until you run .kb_edit().

因此,第一次点击运行 .kb_edit(),它会设置点击处理程序。

So the first click runs .kb_edit(), which sets up the click handler.

然后,第二次点击实际上会触发第一次点击设置的内容。

Then the second click actually gets to trigger whatever was set up by the first click.

这篇关于在javascript函数中的jquery需要两次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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