prison47,
$.fn.pluginNew = function(options) { return this.each(function(){ if ($(this).data('on')) return; $(this).data('on', true) // do stuff }); } |
Странно но почему то не работает. Если я правильно понял нужно так?:
$.fn.pluginNew = function(options) { return this.each(function(){ if ($(this).data('on')) return; $(this).data('on', true) foo.on(....); }); } |
Странно, тот же код, но почему то работает...
<script src="//code.jquery.com/jquery-latest.min.js"></script> <script> (function($) { $.fn.pluginNew = function(options) { return this.each(function(){ if ($(this).data('on')) return; $(this).data('on', true) /*foo.on(....);*/alert('Че-нибудь делаем'); }); } } (jQuery) ); </script> <button onclick="$(this).pluginNew()">Нажми меня полностью</button> |
Точнее я неправильно выразился :) Работать то работает но все равно дублирует
|
prison47,
код дубляжа можно? |
prison47, но ведь алерт вылетает только при первом нажатии. Значит все ок :)
|
$body.on('click.noteOverlay', '#general_overlay', function(){ var genThis = $(this).siblings('[data-case]'); removeOverCase(genThis); }); |
prison47,
лучше небольшое демо чем часть кода |
prison47, это решение всех твоих проблем. Изучи как следует:
options = options || {}; index = options.index || 0; if (!selector || options.live === false) { that.unbind('click.fb-start').bind('click.fb-start', run); } else { D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run); } this.filter('[data-fancybox-start=1]').trigger('click'); return this; |
Понял, спасибо буду разбираться что к чему!
|
Часовой пояс GMT +3, время: 14:47. |