Code Monkey home page Code Monkey logo

isiaformrepeater's Introduction

isiaFormRepeater

Check out the demo on Codepen: https://codepen.io/vurghusm/pen/zVGjyr

About

isiaFormRepeater is simple and lightweight jquery form repeater plugin.

Wordpress Plugin Repeater Field

You can find a sample demo of how to use isiaFormRepeater in creating repeater fields in Wordpress plugins here

Get started

  • Clone the repository to your dev server.
  • Run npm install
  • Run gulp to compile scripts and start the dev server
  • Browsesync should load the demo in your default browser automatically.
  • If not copy the server address from the command shell and load in your browser to run the demo.
  • Demo is served from ./demo/public folder

Example Use

Reference the following styles in your html header:

<link rel="stylesheet" href="path_to_css_folder/isiaFormRepeater.css" />

Reference the following scripts in your html footer:

<!-- Jquery is a required dependency -->
<script src="path_to_js_folder/jquery.js" type="text/javascript"></script>
<script
  src="path_to_js_folder/isiaFormRepeater.js"
  type="text/javascript"
></script>

Create the repeater element as follows:

<div
  class="isiaFormRepeater repeat-section"
  id="repeaterElement"
  data-field-id="test_field_id"
  data-items-index-array="[1]"
>
  <div class="repeat-items">
    <div class="repeat-item" data-field-index="1">
      <input
        class="repeat-el"
        id="test_field_id[1][test_sub1]"
        name="test_field_id[1][test_sub1]"
      /><input
        class="repeat-el"
        id="test_field_id[1][test_sub2]"
        name="test_field_id[1][test_sub2]"
      />
    </div>
  </div>
</div>
!!!Required HTML parameters
  • data-field-id is specified within the repeater-section. It is the base ID of all repeat-item.
  • data-items-index-array specifies index of repeater-item in the array. E.g A value of [1] is the first item present in the initial form. This value should equivalent to data-field-index in the corresponding repeater-item
  • The id and name of a repeat-el are broken down as follows:
    'test_field_id[1][test_sub1]'
    'test_field_id' is the base id and is equal to the value specified in 'data-field-id'.
    '[1]' the index following the base id is what will increase or decrease when new repeat items are added.
    '[test_sub1]' is the unique identifier for the input field.
    

Initialize the script as follows in the footer:

<script type="text/javascript">
  $(document).ready(function() {
    $("#repeaterElement").isiaFormRepeater();
  });
</script>

isiaformrepeater's People

Contributors

vurghus-minar avatar akfaisel 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.