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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jquery-ctrl

v0.1.0-1

Published

A jQuery plugin for model binding and event binding, looks like angular

Readme

jQuery Ctrl Build Status

A simple, lightweight jQuery plugin for model binding

Download

Download the production version or the development version.

Getting Started

In your web page:

<div jq-ctrl="myCtrl">
  Hello, {{demo}}!
</div>
<script src="jquery.js"></script>
<script src="dist/jquery.ctrl.min.js"></script>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.demo = 'World';
  });
});
</script>

You will see

<div jq-ctrl="myCtrl">
  Hello, world!
</div>

Installation

Include script after the jQuery library (unless you are packaging scripts somehow else):

<script src="dist/jquery.ctrl.min.js"></script>

The plugin can also be loaded as AMD or CommonJS module.

Usage

Value

<div jq-ctrl="myCtrl">
  Hello, {{demo}}!
  <input type="text" jq-model="demo" />
  <button title="{{btn.message}}">{{btn.show}}</button>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.demo = 'World';
    model.btn = {message:'Click',show:'Click Me!'};
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
  Hello, World!
  <input type="text" jq-model="demo" value="World" />
  <button title="Click">Click Me!</button>
</div>

If you type in the input, the word 'World' will change on the same time.

If

<div jq-ctrl="myCtrl">
  I feel
  <span jq-if="happyPoint>5">good</span>
  <span jq-if="happyPoint<=5">not good</span>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.happyPoint = 7;
  });
});
</script>

Yow will get

<div jq-ctrl="myCtrl">
    I feel
    <span jq-if="fine">good</span>
</div>

Repeat

<div jq-ctrl="myCtrl">
    <ul>
        <li jq-repeat="num in numbers">{{num}}</li>
    </ul>
    <ul>
        <li jq-repeat="game in games">{{game.id}}:{{game.name}}</li>
    </ul>
    <ul>
        <li jq-repeat="continent in continents">
            <dl>
                <dt>{{continent.name}}</dt>
                <dd jq-repeat="country in continent.countries">{{country}}</dd>
            </dl>
        </li>
    </ul>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.numbers = [0,1,2,3];
    model.games = [{id:'game01',name:'Football'},{id:'game02',name:'Basketball'}];
    model.continents = [
        {name:'Asia',countries:['China','Pakistan']},
        {name:'European',countries:['French','Germany']}
    ];
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
    <ul>
        <li>0</li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
    <ul>
        <li>game01:Football</li>
        <li>game02:Basketball</li>
    </ul>
    <ul>
        <li>
            <dl>
                <dt>Asia</dt>
                <dd>China</dd>
                <dd>Pakistan</dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>European</dt>
                <dd>French</dd>
                <dd>Germany</dd>
            </dl>
        </li>
    </ul>
</div>

Options

<div jq-ctrl="myCtrl">
    <dl>
        <dt>Array</dt>
        <dd><select jq-model="number" jq-options="numbers"></select></dd>
        <dd>The number selected is {{number}}.</dd>
        
        <dt>Object</dt>
        <dd><select jq-model="game" jq-options="id,name in games"></select></dd>
        <dd>The game selected is {{game}}.</dd>
        
        <dt>Group</dt>
        <dd><select jq-model="country" jq-options="countries"></select></dd>
        <dd>The country selected is {{country}}.</dd>
    </dl>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.numbers = [0,1,2,3];
    model.number = 2;
    model.games = [
	{'id':'game01','name':'Football'},
	{'id':'game02','name':'Basketball'}
    ];
    model.game = 'game02';
    model.countries = [
        {'Asia':['China','Pakistan']},
        {'European':['French','Germany']}
    ];
    model.country = 'China';
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
    <dl>
        <dt>Array</dt>
        <dd>
            <select jq-model="number">
                <option>0</option>
                <option>1</option>
                <option selected="selected">2</option>
                <option>3</option>
            </select>
        </dd>
        <dd>The number selected is 2.</dd>
        
        <dt>Object</dt>
        <dd>
            <select jq-model="game">
                <option value="game01">Football</option>
                <option value="game02" selected="selected">Basketball</option>
            </select>
         </dd>
        <dd>The game selected is game02.</dd>
        
        <dt>Group</dt>
        <dd>
            <select jq-model="country">
                <optgroup label="Asia">
                    <option selected="selected">China</option>
                    <option>Pakistan</option>
                </optgroup>
                <optgroup label="European">
                    <option>French</option>
                    <option>Germany</option>
                </optgroup>
            </select>
        </dd>
        <dd>The country selected is China.</dd>
    </dl>
</div>

If you change the select, the word will change on the same time.

Src / href / Disabled

<div jq-ctrl="myCtrl">
    <a jq-href="{{jqueryLink}}">
        <img jq-src="{{jqueryImage}}" />
    </a>
    <button jq-disabled="btnDisabled">You cannot click me</button>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.jqueryLink = 'http://jquery.com';
    model.jqueryImage = 'http://jquery.com/jquery-wp-content/themes/jquery/images/logo-jquery.png';
    model.btnDisabled = true;
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
    <a jq-href="{{jqueryLink}}" href="http://jquery.com">
        <img jq-src="{{jqueryImage}}" src="http://jquery.com/jquery-wp-content/themes/jquery/images/logo-jquery.png">
    </a>
    <button jq-disabled="btnDisabled" disabled="disabled">You cannot click me</button>
</div>

Style

<div jq-ctrl="myCtrl">
    <span jq-style="style">jQuery.ctrl</span>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.style = {color:'#0f0'};
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
    <span jq-style="style" style="color:#0f0">jQuery.ctrl</span>
</div>

Event

Support click, keypress, keyup, keydown, dbclick, mousedown, mouseup, onmouseover, onmousemove, onmouseout

<div jq-ctrl="myCtrl">
    Click Times: {{clickTimes}}
    <button jq-click="click()">Click Me</button>
</div>
<script>
jQuery(function($) {
  $.ctrl('myCtrl',function(model){
    model.clickTimes = 0;
    model.click = function(){
        model.clickTimes++;
    };
  });
});
</script>

You will get

<div jq-ctrl="myCtrl">
    Click Times: 0
    <button jq-click="click()">Click Me</button>
</div>

The count will plus 1 when you click the button.