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

    Model List Difference (gallery-model-list-difference) on cdn

    Last Updated: 06/23/12
    + 0 -

    Steven Olmsted

    YUI Contributor

    See 42 more by this user.

    Created: 02/13/12
    Last CDN Push: 05/2/13
    Build Tag: gallery-2013.05.02-22-59
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.5.1
    Free for use.

    Creates a model list that is the difference of two or more other model lists. The new model list stays up to date as the source lists change.

    • Tags:
    • solmsted
    • model-list
    • model
    • list
    • difference
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    The static method Y.ModelList.difference returns a model list that is the difference of two or more other model lists.

    The first argument determines the type of model list that is created; it may be a constructor function or a string namespace to a constructor function stored on Y. If the first argument is an instance of ModelList, its constructor is used.

    Then any number of arguments can follow. The remaining arguments should be ModelList instances or arrays of ModelList instances. The order of these model lists is important.

    Code Sample

    <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2013.05.02-22-59'
    }).use('gallery-model-list-difference', function(Y) {
        Y.NameModel = Y.Base.create('NameModel', Y.Model, [], {
        }, {
            ATTRS: {
                name: {
                    value: ''
                }
            }
        });
     
        Y.NameModelList = Y.Base.create('NameModelList', Y.ModelList, [], {
            comparator: function (model) {
                return model.get('name');
            },
            model: Y.NameModel
        });
     
        var nameModel_Emily = new Y.NameModel({
                name: 'Emily'
            }),
            nameModel_Eric = new Y.NameModel({
                name: 'Eric'
            }),
            nameModel_George = new Y.NameModel({
                name: 'George'
            }),
            nameModel_Jeffrey = new Y.NameModel({
                name: 'Jeffrey'
            }),
            nameModel_Jennifer = new Y.NameModel({
                name: 'Jennifer'
            }),
            nameModel_Jim = new Y.NameModel({
                name: 'Jim'
            }),
            nameModel_Kara = new Y.NameModel({
                name: 'Kara'
            }),
            nameModel_Luke = new Y.NameModel({
                name: 'Luke'
            }),
            nameModel_Matthew = new Y.NameModel({
                name: 'Matthew'
            }),
            nameModel_Raymond = new Y.NameModel({
                name: 'Raymond'
            }),
            nameModel_Sarah = new Y.NameModel({
                name: 'Sarah'
            }),
            nameModelList0 = new Y.NameModelList().reset([
                nameModel_Jeffrey,
                nameModel_Emily,
                nameModel_Luke,
                nameModel_Kara,
                nameModel_Eric,
                nameModel_George,
                nameModel_Jim,
                nameModel_Raymond
            ]),
            nameModelList1 = new Y.NameModelList().reset([
                nameModel_Jeffrey,
                nameModel_Emily,
                nameModel_Eric,
                nameModel_Jennifer
            ]),
            nameModelList2 = new Y.NameModelList().reset([
                nameModel_Jeffrey,
                nameModel_George,
                nameModel_Jim
            ]),
            nameModelListDifference = Y.ModelList.difference('NameModelList', nameModelList0, nameModelList1, nameModelList2);
     
        alert(nameModelListDifference.get('name').join(', '));
        // Kara, Luke, Raymond
     
        nameModelList0.add(nameModel_Sarah);
     
        nameModelList0.add(nameModel_Matthew);
     
        nameModelList1.add(nameModel_Matthew);
     
        alert(nameModelListDifference.get('name').join(', '));
        // Kara, Luke, Raymond, Sarah
     
        nameModelList1.reset();
     
        alert(nameModelListDifference.get('name').join(', '));
        // Emily, Eric, Kara, Luke, Matthew, Raymond, Sarah
    });

    © 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