mdbootstrap / bootstrap-templates

A collection for Bootstrap 5 templates.

Home Page:https://mdbootstrap.com/freebies/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flash when duplicate is entered

kritzikratzi opened this issue · comments

its sometimes hard to understand why a tag isn't added when you enter a duplicate. i like it when the existing tag quickly flashes so you know its already there.
not posting this as a pull request because i'm sure it could be done in a nicer way.

  // ~ line 80
  if ($.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0]){
    $.each( self.$container.find( ".tag" ), function( i, e ){
      if( self.options.itemValue( $(this).data( "item" ) ) == itemValue ){
        $(this).hide().fadeIn(); 
      }
    } ); 
    return;
  }

best, hansi.

Nice addition, I implemented this in a1e07e3 (v0.3.7)

I modified the implementation a bit, so that you provide a function in the options (onTagExists), in which you can handle this situation as you like. Default, I implemented the behaviour you suggested (hide and fadeIn).

that was quick. thx, also for the library in general!