GithubHelp home page GithubHelp logo

clearinput's Introduction

ClearInput Backbone component

Backbone.View component to clear the content of an input field. Bring your own input element!

ClearInput example

How to use?

For an example on how to use this, open the ./example/index.html in your browser (browser must be able to make XHR requests, i.e. Chrome, Firefox or you must create a server at the root of the directory).

html structure

You need to wrap the input field that needs the clear input button with an element of class .clear-button-container.

CSS

The basic CSS to make the clear input button work is in style.css. To set the width/height of the input field, make sure you apply the height/width to the .clear-button-container.

JavaScript

var inputElement = document.getElementsByTagName('input')[0];

var clearInput = new ClearInput({
    // inputElement is the DOM Input element that should
    // have clearInput button applied
    input: inputElement
});

// OR:

var clearInput = new ClearInput();
clearInput.setInputElement(inputElement);


// The `clearInput` view takes care of clearing the `input` view,
// hiding and showing itself. 
// If you need to hook into the action (i.e. you need to update
//another part of the page, make an XHR, etc, you can listen for
// the `clear` event, i.e.

clearInput.on('clear', function () {
    // whatever you need to do
});

// if you're using backbone >= 0.9.9, you should can use the
// `#listenTo()` method, to get automatic clean up of your view:

this.listenTo(clearInput, 'clear', function () {
    // whatever you need to do
});

dependencies

For dependency details: component.json

to install (for dev)

dependencies: node.js, npm, bower.js & PhantomJS (for testing)

cd component-clearInput
npm install # installs test dependencies and client-side dependencies

to test

npm test

clearinput's People

Contributors

gillesruppert avatar seldaek avatar willdurand avatar

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.