基本上这个网站:http://dev.supply.net.nz/vendorapp/(目前正在开发中)
我有一些花哨的标签动画在焦点上放入和缩小内容.模糊.
但是,一旦用户登录,浏览器很可能会记住与用户电子邮件地址/登录相关联的密码. (哪个好,不应该被禁用.)
但是,当浏览器自动设置#password字段上的值时,我遇到触发标签滑出动画的问题,因为此事件既不是焦点也不是模糊.
当浏览器“自动填写”用户密码时,是否有人知道使用哪个监听器来运行我的功能?
以下是该问题的快速屏幕截图:
Password Autofill Label Issue http://dl.dropbox.com/u/376243/fill_issue.png
解决方法
引用原文:
The plugin makes use of the trigger() and data() functions. In a nutshell,
we loop over the input element or set
of children input elements,storing
their initial value in the data cache
provided by the data() function. We
then check to see if the stored value
matches the value of the input during
the current iteration. If so,we do
nothing,if not,we manually fire the
change event via trigger(). There’s
also a bit of logic in there to ignore
the element that has focus. We don’t
need to worry about this element,
since if the value is changed while
the user has focus,the change event
will be fired as normal when the
element is blurred.
(function($) { $.fn.listenForChange = function(options) { settings = $.extend({ interval: 200 // in microseconds },options); var jquery_object = this; var current_focus = null; jquery_object.filter(":input").add(":input",jquery_object).focus( function() { current_focus = this; }).blur( function() { current_focus = null; }); setInterval(function() { // allow jquery_object.filter(":input").add(":input",jquery_object).each(function() { // set data cache on element to input value if not yet set if ($(this).data('change_listener') == undefined) { $(this).data('change_listener',$(this).val()); return; } // return if the value matches the cache if ($(this).data('change_listener') == $(this).val()) { return; } // ignore if element is in focus (since change event will fire on blur) if (this == current_focus) { return; } // if we make it here,manually fire the change event and set the new value $(this).trigger('change'); $(this).data('change_listener',$(this).val()); }); },settings.interval); return this; }; })(jQuery);
所有的功劳归于FurryBrains.com的所有者撰写文章.