~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-includes/js/wp-api.js

  • Committer: Jamon Camisso
  • Date: 2017-01-12 15:30:45 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: jamon.camisso@canonical.com-20170112153045-dekfwsu8mcsdxa7x
New upstream release 4.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
                                // Create the new getModel model.
322
322
                                getModel = new wp.api.models[ modelName ]( attributes );
323
323
 
324
 
                                // If we didn’t have an embedded getModel, fetch the getModel data.
325
324
                                if ( ! getModel.get( embedCheckField ) ) {
326
 
                                        getModel.fetch( { success: function( getModel ) {
327
 
                                                deferred.resolve( getModel );
328
 
                                        } } );
 
325
                                        getModel.fetch( {
 
326
                                                success: function( getModel ) {
 
327
                                                        deferred.resolve( getModel );
 
328
                                                },
 
329
                                                error: function( getModel, response ) {
 
330
                                                        deferred.reject( response );
 
331
                                                }
 
332
                                        } );
329
333
                                } else {
 
334
                                        // Resolve with the embedded model.
330
335
                                        deferred.resolve( getModel );
331
336
                                }
332
337
 
392
397
 
393
398
                                // If we didn’t have embedded getObjects, fetch the getObjects data.
394
399
                                if ( _.isUndefined( getObjects.models[0] ) ) {
395
 
                                        getObjects.fetch( { success: function( getObjects ) {
 
400
                                        getObjects.fetch( {
 
401
                                                success: function( getObjects ) {
396
402
 
397
 
                                                // Add a helper 'parent_post' attribute onto the model.
398
 
                                                setHelperParentPost( getObjects, postId );
399
 
                                                deferred.resolve( getObjects );
400
 
                                        } } );
 
403
                                                        // Add a helper 'parent_post' attribute onto the model.
 
404
                                                        setHelperParentPost( getObjects, postId );
 
405
                                                        deferred.resolve( getObjects );
 
406
                                                },
 
407
                                                error: function( getModel, response ) {
 
408
                                                        deferred.reject( response );
 
409
                                                }
 
410
                                        } );
401
411
                                } else {
402
412
 
403
413
                                        // Add a helper 'parent_post' attribute onto the model.
1234
1244
                                                },
1235
1245
 
1236
1246
                                                // Specify the model that this collection contains.
1237
 
                                                model: loadingObjects.models[ modelClassName ],
 
1247
                                                model: function( attrs, options ) {
 
1248
                                                        return new loadingObjects.models[ modelClassName ]( attrs, options );
 
1249
                                                },
1238
1250
 
1239
1251
                                                // Include a reference to the original class name.
1240
1252
                                                name: collectionClassName,
1257
1269
                                                url: routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName,
1258
1270
 
1259
1271
                                                // Specify the model that this collection contains.
1260
 
                                                model: loadingObjects.models[ modelClassName ],
 
1272
                                                model: function( attrs, options ) {
 
1273
                                                        return new loadingObjects.models[ modelClassName ]( attrs, options );
 
1274
                                                },
1261
1275
 
1262
1276
                                                // Include a reference to the original class name.
1263
1277
                                                name: collectionClassName,