I'm looking at a class
(this one). The doco for it suggests you can extend
the class to change a property of the class. That is true, it works for me.
However what I want to do is dynamically provide the values for the setting.
I've got two questions.
First
How can I adapt the demo so that I can dynamically supply the values used.
Second
I realise when I look at the class, this seems to be the significant part of the code ...
ajax (url, data = {}, method = this.method) {
const ajaxSettings = assign(
{},
{
contentType: false,
processData: false,
xhr: () => {
const xhr = $.ajaxSettings.xhr();
xhr.upload.onprogress = (event) => {
this.didProgress(event);
};
this.one('isAborting', () => xhr.abort());
return xhr;
},
url,
data,
method
},
get(this, 'ajaxSettings')
);
return this.ajaxPromise(ajaxSettings);
},
... I'm not confident that I understand how the 'extend' is doing what it's doing . ajaxSettings
is used within the ajax
function so how does the extend
reach within the function and merge the value provided in the extend into the hardcoded values in the function ?
Hope the question makes sense ... I'll happily settle for an answer to 'First' if you can't manage 'Second' without writing a book ;-)
Aucun commentaire:
Enregistrer un commentaire