开发者

How do I add a destroy method in jQuery CoolInput?

开发者 https://www.devze.com 2022-12-27 15:05 出处:网络
I am looking at: CoolInput, but I need a destroy method. I want to be able to do something like this: $(\'#manualhint2\').coolinput(\'foobar\');

I am looking at: CoolInput, but I need a destroy method.

I want to be able to do something like this:

$('#manualhint2').coolinput('foobar');

but I also need a method like:

$('#manualhint2').coolinput(destroy);  

or something like that, because there ar开发者_C百科e times when I need to disable CoolInput.

Can somebody please help me?

Or, you can also recommend another jquery hint library that has a destroy method.

Thanks!


Have you tried

$('#manualhint2').coolinput(''); 

?


With a bit explore in CoolInput code, I got this:

$(selector).each(function () {
  EmptyThisCoolInput($(this));
});

function EmptyThisCoolInput(o) {
  try {
    if (o.val() == o.attr(coolInputAttribute) && o.hasClass(coolinputBlurClass))
      o.val("").removeClass(coolinputBlurClass);
  } catch (e) { }
}

I separated EmptyThisCoolInput because I call this somewhere else. you can safely use this syntax:

$(selector).each(function () {
  try {
    if ($(this).val() == $(this).attr(coolInputAttribute) && $(this).hasClass(coolinputBlurClass))
      $(this).val("").removeClass(coolinputBlurClass);
  } catch (e) { }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号