Coder Social home page Coder Social logo

fuadarradhi / jquery.add-remove Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abirchler/jquery.add-remove

0.0 1.0 0.0 33 KB

jQuery plugin for dynamically adding and removing "rows" to an element.

License: MIT License

HTML 20.14% JavaScript 70.78% CSS 9.08%

jquery.add-remove's Introduction

jquery.add-remove

jQuery plugin for dynamically adding and removing "rows" to an element.

This project is under development and is not at a stable point.

Demo

https://aaronbirchler.com/jquery.add-remove/test.html

To Do

  • Add option to remove template
  • Add option to use template from not within the container
  • Add option to add add & remove buttons
  • Add min-rows option
  • Add max-rows option
  • Handle nested instances
  • Handle renaming of input elements
  • Handle ids to avoid duplicates
  • Add hooks & callbacks
  • Add ability to confirm removal
  • Handle "no rows" situation

Options

  • addButton: Selector used to find the add buttons
  • autoFocus: Put focus on first input of newly added row
  • clearValues: Clears the values from input elements when adding a new row
  • container: Selector used to find the container to which rows are added
  • modifyId: Function used to modify the ids of elements. Passed the old id and the row number
  • modifyName: Function used to modify the names of elements. Passed the old name and row number
  • removeButton: Selector used to find the remove buttons
  • removeTemplate: Whether to remove the original template or not
  • template: Selector used to find the template which rows are cloned from

Events

  • add_row:add
  • add_row:empty
  • add_row:max
  • add_row:max_clear
  • add_row:min
  • add_row:min_clear
  • add_row:remove
  • add_row:renumber

Example Usage

HTML

<form>
  <div id="container">

    <ul>
      <li>

        <span>
          <label for="test-field-1">Test Field</label>
          <input type="text" id="test-field-1" name="test_field[1]"/>
        </span>

        <button class="remove-button" type="button">Remove</button>

      </li>
    </ul>

    <button type="button" id="add-button" class="add-button">Add</button>

  </div>

</form>

JavScript

jQuery(function($){
  $("#container").addRemove();
});

jquery.add-remove's People

Contributors

abirchler avatar

Watchers

James Cloos 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.