I am new to Backbone
, so can’t understand what I am doing wrong. What I need is to override saveCompat (media-models.js
line 310
, WP 3.9.1
). I am trying to do it same way I have overridden some media views
wp.media.model.Attachment = wp.media.model.Attachment.extend({
saveCompat: function( data, options ) {
some code here...
}
});
But it doesn’t work for me. Native WordPress saveCompat
is executed. At the same time the very same idea is perfectly working for wp.media.view.AttachmentCompat
for example
wp.media.view.AttachmentCompat = wp.media.view.AttachmentCompat.extend({
save: function( event ) {
some code here...
}
});
Thanks in advance!
I figured it out. The correct way to extend it is:
Using
_.extend
removes the ability to call the super class implementation of methods. The proper (or at least a working) way to do it is to use Backbone’sextend
method and then overwrite the prototype inwp.media.model.Attachment
like this: