• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Plugin activation attributes (gallery-pluginattr) on cdn

    Last Updated: 07/28/11
    + 0 -

    Luke Smith

    YUI Contributor

    See 19 more by this user.

    Created: 07/28/11
    Last CDN Push: 08/3/11
    Build Tag: gallery-2011.08.03-21-18
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.4.0 PR3
    Free for use.


    var instance = new Y.SomeClass({ ... });
    instance.plug(Y.Plugin.Drag);

    is a nuisance. I want the instantiation of my class to describe its makeup entirely. Two is one too many steps.

    So this module allows you to have plugins register a triggering attribute on host classes that will do the magic for you under the hood.


    // Add the attribute 'draggable' to Y.SomeClass to (un)plug Y.Plugin.Drag
    Y.Plugin.addHostAttr('draggable', Y.SomeClass, Y.Plugin.Drag);


    var instance = new Y.SomeClass({
    ...,
    draggable: true
    });

    See the linked docs for more details and extended signature.

    • Tags:
    • attribute
    • lsmith
    • plugin
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Example 1.
    Add "draggable" triggering attribute to Y.DataTable.Base:

    Example 2.
    Add a triggering attribute "filters" that accepts true|false or
    a configuration object (out-of-the-box support), as well as a single
    string or string array to pass as the plugin's "category" configuration

    Code Sample

    <script src="http://yui.yahooapis.com/3.4.0 PR3/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2011.08.03-21-18'
    }).use('datatable-sort', 'console-filters', 'gallery-pluginattr', function(Y) {
     
    // Example 1.
    Y.Plugin.addHostAttr('sortable', Y.DataTable.Base, Y.Plugin.DataTableSort);
     
    var table = new Y.DataTable.Base({ sortable: true }); // plugs DTSort
    table.set('sortable', false); // unplugs DTSort
     
     
    // Example 2.
    Y.Plugin.addHostAttr('filters', Y.Console, Y.Plugin.ConsoleFilters,
         function (config) {
             if (Y.Lang.isString(config) || Y.Lang.isArray(config)) {
                 config = {
                     defaultVisibility: false,
                     category: Y.Array.hash(Y.Array(config))
                 };
             }
     
            return config;
        }
    });
     
    var con = new Y.Console({ filters: ['warn', 'error'] });
     
    });

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info