function create( dataView, $el, options ) {

      var dfd = $.Deferred();

      dfd.then(function() { delete _view_creating[dataView]; }, function() { delete _view_creating[dataView]; } );

      _view_creating[dataView] = dfd;

      load( dataView ).then( function( view ) {

         var inst = new view(_.extend( options, { el: $el[0] } )),
             parent, fizzle = false;

         $el.attr( 'data-cid', inst.cid );
         _view_inst[inst.cid] = inst;

         parent = $el.parents( '[data-view]' ).first();

         if ( parent.length > 0 ) {
            parent = parent.attr( 'data-cid' );
            if ( _view_inst[parent] ) {
               _view_inst[parent].addChild( inst );
               inst.setParent( _view_inst[parent] );
            } else {
               fizzle = true;
               inst.remove();
            }
         } else if ( $el.closest('body').length === 0 ) {
            fizzle = true;
            inst.remove();
         }

         if (!fizzle) {
            inst.render();
            dfd.resolve( inst );
         } else {
            dfd.reject();
         }

      }, function() { dfd.reject(); } );

   }
/**
   *  View factory method.  Creates instance, sets up the parent/child
   *  relationship and renders the view.
   */
View factory method.  Creates instance, sets up the parent/child
relationship and renders the view.
View factory method . Creates instance sets up the parent / child relationship and renders the view .
function create( dataView, $el, options ) {
      var dfd = $.Deferred();
      dfd.then(function() { delete _view_creating[dataView]; }, function() { delete _view_creating[dataView]; } );
      _view_creating[dataView] = dfd;
      load( dataView ).then( function( view ) {
         var inst = new view(_.extend( options, { el: $el[0] } )),
             parent, fizzle = false;
         $el.attr( 'data-cid', inst.cid );
         _view_inst[inst.cid] = inst;
         parent = $el.parents( '[data-view]' ).first();
         if ( parent.length > 0 ) {
            parent = parent.attr( 'data-cid' );
            if ( _view_inst[parent] ) {
               _view_inst[parent].addChild( inst );
               inst.setParent( _view_inst[parent] );
            } else {
               fizzle = true;
               inst.remove();
            }
         } else if ( $el.closest('body').length === 0 ) {
            fizzle = true;
            inst.remove();
         }
         if (!fizzle) {
            inst.render();
            dfd.resolve( inst );
         } else {
            dfd.reject();
         }
      }, function() { dfd.reject(); } );
   }
function create ( dataView , $el , options ) { var dfd = $ . Deferred ( ) ; dfd . then ( function ( ) { delete _view_creating [ dataView ] ; } , function ( ) { delete _view_creating [ dataView ] ; } ) ; _view_creating [ dataView ] = dfd ; load ( dataView ) . then ( function ( view ) { var inst = new view ( _ . extend ( options , { el : $el [ 0 ] } ) ) , parent , fizzle = false ; $el . attr ( 'data-cid' , inst . cid ) ; _view_inst [ inst . cid ] = inst ; parent = $el . parents ( '[data-view]' ) . first ( ) ; if ( parent . length > 0 ) { parent = parent . attr ( 'data-cid' ) ; if ( _view_inst [ parent ] ) { _view_inst [ parent ] . addChild ( inst ) ; inst . setParent ( _view_inst [ parent ] ) ; } else { fizzle = true ; inst . remove ( ) ; } } else if ( $el . closest ( 'body' ) . length === 0 ) { fizzle = true ; inst . remove ( ) ; } if ( ! fizzle ) { inst . render ( ) ; dfd . resolve ( inst ) ; } else { dfd . reject ( ) ; } } , function ( ) { dfd . reject ( ) ; } ) ; }
View factory method.
View factory method .