forked from DGNum/gestioCOF
Change fromAPI logic
This commit is contained in:
parent
840010b63f
commit
1761c5f1bd
|
@ -754,24 +754,14 @@ class APIModelForest extends ModelForest {
|
||||||
* Fills the instance with distant data. It sends a GET HTTP request to
|
* Fills the instance with distant data. It sends a GET HTTP request to
|
||||||
* {@link Models.APIModelForest#url_model}.
|
* {@link Models.APIModelForest#url_model}.
|
||||||
* @param {object} [api_options] Additional data appended to the request.
|
* @param {object} [api_options] Additional data appended to the request.
|
||||||
* @param {jQueryAjaxSuccess} [on_success] A function to be called if the request succeeds.
|
|
||||||
* @param {jQueryAjaxError} [on_error] A function to be called if the request fails.
|
|
||||||
*/
|
*/
|
||||||
fromAPI(api_options, on_success, on_error) {
|
fromAPI(api_options) {
|
||||||
var that = this;
|
api_options = api_options || {};
|
||||||
|
|
||||||
api_options = api_options || {}
|
|
||||||
on_success = on_success || $.noop;
|
|
||||||
on_error = on_error || $.noop;
|
|
||||||
|
|
||||||
api_options['format'] = 'json';
|
api_options['format'] = 'json';
|
||||||
|
|
||||||
$.getJSON(this.constructor.url_model, api_options)
|
return $.getJSON(this.constructor.url_model, api_options)
|
||||||
.done(function(json, textStatus, jqXHR) {
|
.done( (json) => this.from(json) );
|
||||||
that.from(json);
|
|
||||||
on_success(json, textStatus, jqXHR);
|
|
||||||
})
|
|
||||||
.fail(on_error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,8 @@ class ArticleManager {
|
||||||
reset_data() {
|
reset_data() {
|
||||||
this._$container.html('');
|
this._$container.html('');
|
||||||
this.list.clear();
|
this.list.clear();
|
||||||
this.list.fromAPI({}, this.display_list.bind(this), $.noop) ;
|
this.list.fromAPI()
|
||||||
|
.done( () => this.display_list() );
|
||||||
}
|
}
|
||||||
|
|
||||||
get_article(id) {
|
get_article(id) {
|
||||||
|
|
Loading…
Reference in a new issue