Giter Club home page Giter Club logo

metallurgical / jquery-metal-clone Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 7.0 194 KB

jQuery Plugin to Clone HTML DOM element without needed doing it yourself, this plugin will take care of everything. Just seat and drink coffee!

Home Page: https://metallurgical.github.io/jquery-metal-clone

License: MIT License

CSS 4.09% JavaScript 71.50% HTML 24.40%
jquery jquery-clone dom-clone jquery-metal jquery-plugin dom-element metal-clone jquery-copy-html jquery-duplicate-html hacktoberfest

jquery-metal-clone's Introduction

build status npm version license Total npm downloads

Jquery Metal Clone Plugin

Simple plugin to clone HTML DOM element.

Features

  • Easy to implement together with HTML markup.
  • Enable placing the cloned element into defined destination.
  • Specified position cloned element.
  • Clone the element as many as you want.
  • With unique ID(s) auto increment.
  • Clone table rows even column also.
  • Limit the number of cloned element into specified value.
  • Available callback to listen when some action triggered.
  • Support for font awesome 5.
  • Many more..

Current Stable

How To Install

Bower

bower install jquery-metal-clone --save

Yarn

yarn add jquery-metal-clone

Npm

npm install jquery-metal-clone --save

Installation is so very easy. Download the current stable and see the example in Demo page. Here is the manual step to follow :

  1. Put <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> inside Head Section(recommended using latest version).
  2. Put <script src="path/to/jquery.metalClone.min.js"></script> after jQuery library.
  3. Put <link src="path/to/metalClone.css" rel="stylesheet">.
  4. Done!!

Documentation & Demo

Navigate to Documentation.

Dependencies

  • Font awesome [Can be disable via provided option]

Support

  • If you found a bug or something technical problem, please open an issues.
  • If the example/usage above did't clear enough, leave me some note by sending email at [email protected]
  • If encountered any problems, just ask it from stackoverflow.com by using this tag : jquery-metal-clone
  • Spread the words about this plugin :)

Changelog

View Changelog

jquery-metal-clone's People

Contributors

iphadey avatar jeffsmonteiro avatar metallurgical avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jquery-metal-clone's Issues

How to repopulate

How to list cloned elements from a registered database list. I tried to do with foreach and add the remove button. But it did not work!

<?php foreach ($fonts as $i => $font): $randonId = rand(); ?>
   <div class="<?php echo 'metalElement' . $randonId; ?>" data-clone-it>
    <div class="form-group">
        <?php echo form_dropdown('data[fonts][]', $fonts, $font, 'class="form-control"'); ?>
     </div>
     <?php if($i > 0): ?>
        <button type="button" class="<?php echo 'metalElement' . $randonId . 'BtnRemove'; ?> metal-btn-remove button button-danger button-block" style="margin-bottom: 20px" data-metal-ref="<?php echo '.metalElement' . $randonId; ?>">
              <i class="fa fa-trash-o"></i> 
                  Delete
               </button>
        <?php endif; ?>
    </div>
<?php endforeach;?>

removeBtn custom button

Can you add on next version such option?
For making REMOVE button as defined element without clonin it.
For example

[Add row .cloneBtn] [Remove row .removeBtn]

Exceptions for the copyValue parameter (false)

copyValue is a very hard parameter and sometimes you may want to keep values ​​of certain elements, with for example, hidden fields.

To fit your beautiful plugin to my needs, I created a new parameter for it: clearExceptions

(...)
currentClearExceptions = opt.clearExceptions,
(...)

function clearForm (container) {
  container.find ('input: not (input [type = button], input [type = submit], input [type = checkbox], input [type = radio] "), textarea, select' ) {
    $ (this) .not (currentClearExceptions) .val ('');
  });
}

(... fn.metalClone.defaults)
clearExceptions: '', // Make exception for elements that you do not want to clear

Where can I pass the new option informing the name of the elements of which I want to keep a copy of the value

Example:

$ ('. group'). metalClone ({
  btnClone: ​​'# btnAdd',
  copyValue: false,
  clearExceptions: '#current_user_id',
  enableAnimation: false,
});

Unique ID for name

I think we should implement auto unique id for name attribute. Just the same way as it is for id attribute.

There are so many backend developers who would use something like this in their html.

<input name="attendees[0][first_name]" type="text">
<input name="attendees[1][first_name]" type="text">
<input name="attendees[2][first_name]" type="text">

What do you guys think?

Not compatible with jQuery 3.x - created jsFiddles demonstrating

Great looking plugin but it doesn't work with jQuery 3.2.1 and I was hoping to get some assistance.

I'm using the example #2 from the web site (metalClone):

<div class="toClone_example2">
<input type="text">
<select id="m">
<option value="">--Please Select</option>
<option value="Hello">Hello</option>
</select>
</div>
<div class="container_body">
<input type="button" class="btn_example2" value="Create New Copy">
</div>
and the js:

// Example 2
$('.toClone_example2').metalClone({
btnClone : '.btn_example2',
copyValue : true
})

Here is a jsFiddlel working with jQuery 2.3x
https://jsfiddle.net/SavageCatHV/nseawghs/

and here is the jsFiddle with jQuery 3.3.x
https://jsfiddle.net/SavageCatHV/nseawghs/1/

You'll need to open the console window.

installation with npm error in laravel mix

After npm intall, in app.js add
require('jquery-metal-clone')

then npm run watch

the ouput error : ERROR in ./js/app.js
Module not found: Error: Can't resolve 'jquery-metal-clone' in '/var/www/html/app/js'
@ ./js/app.js 19:0-29
@ multi ./js/app.js

i made the same process for
require('bootstrap-sass');
require('select2');
require('rangeslider.js');
require('parsleyjs');
require('parsleyjs/dist/i18n/fr');
require('parsleyjs/dist/i18n/fr.extra');
require('slick-carousel');
require('jquery-touchswipe');

and all is working fine

error with webpack laravel mix

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.