npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-rowtool

v0.0.1

Published

jQuery plugin for dynamically adding rows to a table based on a qty input.

Downloads

3

Readme

jQuery rowTool

Dynamically add rows to a table from a Qty. input

Here's the job: you need to dymically add a whole bunch of rows to a table, based on a qty. input box. You don't want to write the same 100 lines of code all the time.

Here's the solution: use this plugin!

This plugin will automatically ensure that the rows are added and removed from the table.

Limits can be placed (min and max values on the qty. input box)

You can add rows on the server side, this plugin will not clobber them.

Usage

  1. Include jQuery:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  2. Include plugin's code:

    <script src="dist/jquery.rowtool.min.js"></script>
  3. Write the HTML:

    <p>How many things do you want?</p>
    <input id="service-qty" name="service-qty" type="number" value="0" min="0" max="99" aria-valuemin="1">
       
        
    <!-- build a template for the rows... -->
    <script type="html/service-template" name="service-template">
        <tr class="service">
            <td>#<span class="service-qty-number"></span></td>
            <td><input type="text" name="service[][nickname]" placeholder="Nicky"></td>
            <td><input type="text" name="service[][firstname]" placeholder="Nicholas"></td>
            <td><input type="text" name="service[][lastname]" placeholder="Jonas"></td>
        </tr>
    </script>
        
    <!-- and add a table that we will modify! -->
    <table class="services">
        <thead>
        <tr>
            <th>ID</th>
            <th>Nick name</th>
            <th>First name</th>
            <th>Last name</th>
        </tr>
        </thead>
        <tbody>
    
        </tbody>
    </table>
  4. Call the plugin:

    $(".services").rowTool({
        // The template for the row.
        template: $('script[type="html/service-template"][name="service-template"]'),
          
        // This is the name of the input box(es) that we want to modify
        groupName: 'service',
          
        // The input boxes are called this...
        inputBoxes: ['nickname', 'firstname', 'lastname'],
          
        // This is the element with the input box that has the qty.
        // When it changes, we want to update the table with this # of rows
        qtyInput: $("#service-qty"),
          
        // [Optional] This is the class that has the # of the row.
        qtyRow: ".service-qty-number",
    
        // [Optional] Callbacks when an element is ready.
        inputBoxReady: {
            nickname: function($nickname) {
                $nickname.on('change', function() {
                    console.log($(this).val();
                });
            }
        }
    });

Structure

The basic structure of the project is given in the following way:

├── demo/
│   └── index.html
├── dist/
│   ├── jquery.rowtool.js
│   └── jquery.rowtool.min.js
├── src/
│   └── jquery.rowtool.js
├── .editorconfig
├── .gitignore
├── .jshintrc
├── .travis.yml
├── Gruntfile.js
└── package.json

demo/

Contains a simple HTML file to demonstrate the plugin.

License

Software is licensed under the MIT License.

© Vonex, 2016