]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/wp-api.js
WordPress 4.7.1-scripts
[autoinstalls/wordpress.git] / wp-includes / js / wp-api.js
index a14d21fae6179c911483489d6b37aacaa16ded70..ccda6a0e8b7891cb930baceeb858ca10d2c2e435 100644 (file)
                                // Create the new getModel model.
                                getModel = new wp.api.models[ modelName ]( attributes );
 
-                               // If we didn’t have an embedded getModel, fetch the getModel data.
                                if ( ! getModel.get( embedCheckField ) ) {
-                                       getModel.fetch( { success: function( getModel ) {
-                                               deferred.resolve( getModel );
-                                       } } );
+                                       getModel.fetch( {
+                                               success: function( getModel ) {
+                                                       deferred.resolve( getModel );
+                                               },
+                                               error: function( getModel, response ) {
+                                                       deferred.reject( response );
+                                               }
+                                       } );
                                } else {
+                                       // Resolve with the embedded model.
                                        deferred.resolve( getModel );
                                }
 
 
                                // If we didn’t have embedded getObjects, fetch the getObjects data.
                                if ( _.isUndefined( getObjects.models[0] ) ) {
-                                       getObjects.fetch( { success: function( getObjects ) {
+                                       getObjects.fetch( {
+                                               success: function( getObjects ) {
 
-                                               // Add a helper 'parent_post' attribute onto the model.
-                                               setHelperParentPost( getObjects, postId );
-                                               deferred.resolve( getObjects );
-                                       } } );
+                                                       // Add a helper 'parent_post' attribute onto the model.
+                                                       setHelperParentPost( getObjects, postId );
+                                                       deferred.resolve( getObjects );
+                                               },
+                                               error: function( getModel, response ) {
+                                                       deferred.reject( response );
+                                               }
+                                       } );
                                } else {
 
                                        // Add a helper 'parent_post' attribute onto the model.
                                                },
 
                                                // Specify the model that this collection contains.
-                                               model: loadingObjects.models[ modelClassName ],
+                                               model: function( attrs, options ) {
+                                                       return new loadingObjects.models[ modelClassName ]( attrs, options );
+                                               },
 
                                                // Include a reference to the original class name.
                                                name: collectionClassName,
                                                url: routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName,
 
                                                // Specify the model that this collection contains.
-                                               model: loadingObjects.models[ modelClassName ],
+                                               model: function( attrs, options ) {
+                                                       return new loadingObjects.models[ modelClassName ]( attrs, options );
+                                               },
 
                                                // Include a reference to the original class name.
                                                name: collectionClassName,