• 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

    Build Tag: gallery-2012.10.10-19-59

    Return to Multiple Model Sync

    // Defining a custom Model object within a custom module.
    YUI.add('my-model', function (Y, moduleName) {
        Y.MyModel = Y.Base.create(moduleName, Y.Model, [
            Y.ModelSync.Local,
            Y.ModelSync.YQL,
            Y.ModelSync.Multi // This comes after the other sync extensions.
        ], {
            parse : function (results) {
                return results && results.entry && results.entry.length && results.entry[0];
            },
            // This query will select the most recent edits to Wikipedia.
            query: "select * from atom where url='http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=atom'",
            root: moduleName
        }, {
            SYNCS: { // The SYNCS property gives each sync extension a unique name.
                local: Y.ModelSync.Local,
                yql: Y.ModelSync.YQL
            }
        });
    }, '', {
        requires: [
            'gallery-model-sync-local',
            'gallery-model-sync-multi',
            'gallery-model-sync-yql',
            'model'
        ]
    });
     
    // The application starts here.
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2012.10.10-19-59'
    }).use('my-model', 'node', function (Y) {
        // Create an instance of the custom model.
        var myModel = new Y.MyModel();
     
        myModel.load({
            sync: 'yql' // Specify which sync layer is used for load.
        }, function (error) {
            if (error) {
                Y.log(error, 'error');
                return;
            }
     
            myModel.save({
                sync: 'local' // Specify which sync layer is used for save.
            }, function (error) {
                if (error) {
                    Y.log(error, 'error');
                    return;
                }
     
                // Display the content from localStorage to prove it worked.
                // It should show a json string containing data about the most recent edit to Wikipedia.
                Y.one('body').append('<pre>' + localStorage.getItem('my-model') + '</pre>');
            });
        });
    });

    Build Output

    /home/y/libexec/ant/bin/ant all
    Buildfile: build.xml
         [echo] Starting Build For gallery-model-sync-multi
    
    clean:
    
    init:
        [mkdir] Created dir: /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp
         [echo] Starting Build For gallery-model-sync-multi
    
    -lint-server:
         [echo] Starting Build For gallery-model-sync-multi
    
    -node:
         [echo] For faster builds, install Node.js.
    
    -concatdebug:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/ant
       [delete] Deleting directory /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/ant
    
    -registerdebug:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp
    
    -prependdebug:
    
    -appenddebug:
    
    builddebug:
    
    -createcore:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp
    
    -loggerregex:
    
    buildcore:
    
    -rollupjs:
    
    -concatskins:
    
    -buildskins:
    
    -rollupcss:
    
    buildskins:
    
    -buildlangs:
    
    -rolluplangs:
    
    buildlangs:
    
    build:
    
    build-coverage:
         [echo] Creating coverage file for: /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/gallery-model-sync-multi.js
         [move] Moving 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp
         [move] Moving 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp
    
    minify:
    [yuicompressor] Compressing /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/gallery-model-sync-multi.js
    [yuicompressor] 
    [yuicompressor] [WARNING] Invalid hint syntax: use strict
    [yuicompressor] Y){(function(Y){ ---> "use strict" <--- ;var _class=function(){};
    [yuicompressor] Compressed to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/gallery-model-sync-multi-min.js
    
    lint:
         [echo] Using Rhino. Install nodejs to improve jslint speed, or skip with -Dlint.skip=true
         [java] Running JSLint on : /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-model-sync-multi/build_tmp/gallery-model-sync-multi.js
         [java] - OK
    
    local:
    
    deploybuild:
         [copy] Copying 4 files to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/build/gallery-model-sync-multi
    
    deployassets:
    
    deployskins:
    
    deploylang:
    
    deploydocs:
    
    deploy:
    
    all:
    
    BUILD SUCCESSFUL
    Total time: 2 seconds

    © 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