Jets.js icon indicating copy to clipboard operation
Jets.js copied to clipboard

Add custom attrName

Open dougaraujos opened this issue 8 years ago • 9 comments

Just sharing a custom feature: I needed more searches for the same element. So I decided to add a attrName with custom name for each instance.

dougaraujos avatar May 30 '16 18:05 dougaraujos

Hi

I am sorry but I don't get your idea. "custom name for each instance" - exactly this part isn't clear for me

Do you need to search by custom attribute?

NeXTs avatar May 30 '16 19:05 NeXTs

I have three inputs. Each seeks a part of my row. But without the custom attribute, the Jets just search for 'data-jets'. So attrName added for each input.

instance = new Jets({attrName: 'data-jets-' + name, ... });

dougaraujos avatar May 30 '16 19:05 dougaraujos

Use manualContentHandling, see in options There are example how to handle custom attributes :)

new Jets({
  ...
  manualContentHandling: function(tag) {
    return tag.getAttribute('custom-attr-name');
  }
});

NeXTs avatar May 30 '16 19:05 NeXTs

The problem is that each input search a portion of the element only. However, when instantiate three times, the CSS rule changes the display only for the data-jets. What I needed was this:

#table-components>:not([data-jets-name*="a"]){display:none} #table-components>:not([data-jets-price*="100"]){display:none} #table-components>:not([data-jets-time*="3"]){display:none}

dougaraujos avatar May 30 '16 20:05 dougaraujos

Ok. now I see what you want

NeXTs avatar May 30 '16 20:05 NeXTs

Let's wait for +1's to see if anyone else need this feature

NeXTs avatar Jul 18 '16 07:07 NeXTs

dougaraujos can I use your code? fits best for my problem

matteoannibali avatar Sep 18 '16 19:09 matteoannibali

(Sorry for the delay)

Implement an example in Codepen (using Jets.js - v0.9.0 - 2016-04-26) http://codepen.io/dougaraujos/pen/bwjoYR

dougaraujos avatar Oct 14 '16 13:10 dougaraujos

I needed to sort a massive dataset on many different data attributes, so a custom attribute name is a must!

allanlaal avatar Feb 01 '18 19:02 allanlaal