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.mydata

v0.4.5

Published

Small JQuery&Zepto plugin for two-ways data binding.

Downloads

4

Readme

jQuery.MyData

Latest Stable Version Total Downloads License Build Status

Small jQuery&Zepto plugin for two-ways data binding.

Install

Composer:

$ php composer.phar require "ange007/jquery-mydata"

Bower:

$ bower install --save-dev ange007/jquery-mydata

Initialize

$( /* parentElement */ ).myData( /* data and event object */, /* callback from all actions */ );
$( /* parentElement */ ).myData( /* options object */, /* callbacks object */ );
$( 'body' ).myData( object, function( type, element, propName, value, data ) { ... } );
$( 'body' ).myData( { event: eventObject, data: dataObject }, function( type, element, propName, value, data ) { ... } );
$( 'body' ).myData( data, {
	main: function( type /* event type */, element, propName, value, data ) { ... }, // Main callback from all actions
	set: function( element, propName, value, data /* [ eventType ] */ ) { ... }, // Callback from SET action
	get: function( element, propName, value, data /* [ ] */ ) { ... }, // Callback from GET action
	on: function( element, propName, value, data /* [ eventType, callArgs ] */ ) { ... } // Callback from ON action
} );

Options

  • event (object) - object for [data-on] actions.
  • data (object) - object for [data-bind] actions.
  • exlusive (boolean, default: false) - recreate plugin and event listeners if the plugin has already been used on this element.
  • data-keys (object) - keys for working with data and events:
    • event (string, default: 'data-on')
    • event-value (string, default: 'data-on-value')
    • data (string, default: 'data-bind')
    • data-element (string, default: 'data-bind-element')

Uses

Data Binding (control-to-object)

{
	var data = { 
		'time': getTime( ),
		'check': false,
		'test': function( value, elementData /* [ element, elementEvent, elementValue ] */ ) { alert( 'Test alert: ' + value ); }
	};

	$( 'body' ).myData( data, function( type, element, propName, value, data )
	{
		if( key === 'text' ) { $( '#text-output' ).html( value ); }
		else if( key === 'check' ) { $( '#text-input' ).attr( 'disabled', !value ); }
	} );
}
/* Output actual time */
<span data-bind="time"></span>

/* Intercepte change state */
<input type="checkbox" data-bind="check"/>

/* Text data transfer */
<label><b>Text input:</b></label> <input id="text-input" type="text" data-bind="text"/>
<div>You write: "<span id="text-output">*</span>"</div>

Action Reaction

/* Function execution */
<a href="#" class="button" data-on="click:test( 'message' )">Test</a>
<input type="checkbox" data-on="console.warn( 'click' )"/>

/* Function execution (custom value) */
<a href="#" class="button" data-on="click:test" data-on-value="message">Test</a>

/* Multiple function execution */
<input type="checkbox" data-on="[ click: console.warn( 'click' ), change: console.warn( 'change' ) ]"/>

Data Binding (control-to-control)

/* Enabled control, and show block */
<input type="checkbox" value="y" data-bind-element="[enabled:#text-element-input,visible:#text-element-block]"/>

<input id="text-element-input" type="text" data-bind-element="text:#text-element-output" disabled/>
<div id="text-element-block" style="visibility: hidden;">You write: "<span id="text-element-output">*</span>"</div>