Code Monkey home page Code Monkey logo

filter-dom-url's Introduction

Filtering data with < input >, < select > & URLSearchParams

Make easy way for filtering data with URLSearchParams & different types of inputs, selects.

npm

release license requests

Build Status Quality Gate Status

Example

A simple demo of usage filter-dom-url

See the code of an example - HTML, JS

Overview

Supported DOM elements types

For tag input:

<input type="..."> - ['checkbox', 'radio', 'color', 'range', 'date', 'month', 'week', 'time']

For tag select:

<select> & <select multiple>

HTML structure

Minimal structure for filter-dom-url initializing:

<form data-filter-form="form-example">
  <input value="value-example" data-filter="type-example" type="checkbox">
</form>

Install

Install package from npm and import:

import Filter from '@kassaila/filter-dom-url';

or copy file or file.min to your project and import:

import Filter from 'dist/filter-dom-url';

Usage

Create Filter instance:

const filterExample = new Filter({
  formAttr: 'data-filter-form="form-example"',
  filterAttr: 'data-filter',
});

API

Parameter Type Arguments Description
init() function - Instance initialization
updateDom() function - Update DOM elements (filters) from URL
setFiltersToUrl(newUrl) function newUrl - object (URL prototype). Base page URL, you can set from window.location Set URLSerchParams to your page URL
getFilters() function - Get object with filters data - { filter-type: ['filter-value'] }

filter-dom-url's People

Contributors

dsymonov-jc avatar kassaila avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dsymonov-jc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.