问题与绑定在jQuery复制元素 [英] Issue with binding in jQuery for copied elements

查看:132
本文介绍了问题与绑定在jQuery复制元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这实际上是一个更大的问题,因为我知道有几种方法可以解决这个问题,但我会尽量总结它。



我试图做的是:我正在使用这个jQuery插件通过Flash http://www.uploadify.com/ 上传文件。然而,我应该绑定这个函数的元素#fileInput是一个活动元素,它在加载页面后生成:$('#fileInput')。uploadify()。 #fileInput是一个活动元素的原因是因为我使用FancyBox来弹出一个DIV,而这个FancyBox基本上只是克隆了DIV的内部html。



发生了什么:当我点击BROWSE上传文件时,没有上传进度条。原因是Uploadify无法绑定到活动元素。



问题:
1.我尝试用uploadify代码中的live()替换bind()但是这并不起作用,因为bind()允许传递[data]。 LiveQuery插件 http://docs.jquery.com/Plugins/livequery 没有与bind()语法相同。如果我不尝试替换bind()方法,那么有没有类似绑定,但适用于实时元素?


  1. 功能并保持uploadify代码相同。有谁知道如何更改FancyBox中的代码,以便它不会生成克隆以生成活动元素?我知道这也是一个难题。

注意:FancyBox网站似乎已经死了 - > http://www.visual-blast.com/javascript/fancybox-jquery-image-zooming- plugin /



非常感谢!

解决方案

您可能会考虑更改FancyBox代码,以便在克隆HTML后支持调用回调函数。然后,将uploadify()调用放入回调函数中。


This is actually a bigger question because I know there are several ways to solve this problem but I will try to sum it up.

What I try to do: I am using this jQuery plugin to upload files via Flash http://www.uploadify.com/. However, the element #fileInput that I supposed to bind this function to is a live element which is generated after the page loaded: $('#fileInput').uploadify(). The reason #fileInput is a live element is because I use FancyBox to popup a DIV and this FancyBox basically just "cloned" the inner html of the DIV.

What happened: When I clicked "BROWSE" to upload a file, there is no progress bar for upload. The reason is because the Uploadify could not bind to live elements.

Questions: 1. I tried to replace bind() with live() in uploadify code but that did not work because bind() allows to pass [data]. The LiveQuery plugin http://docs.jquery.com/Plugins/livequery does not have the same syntax as bind() either. Is there anything similar to bind but works for live elements?

  1. If I don't try to replace bind() function and keep uploadify code the same. Does anyone know how to change code in FancyBox so that it WILL NOT make a clone to generate live elements? I know this is a hard question too.

Note: FancyBox site seems dead --> http://www.visual-blast.com/javascript/fancybox-jquery-image-zooming-plugin/

Thank you very much!

解决方案

You might consider changing the FancyBox code to support calling a callback function after it clones the HTML. Then, put the uploadify() call in the callback function.

这篇关于问题与绑定在jQuery复制元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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