1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
   | export class Collection {
    constructor({id_collection='', nom_collection=''}){
        this.id_collection = id_collection,
        this.nom_collection = nom_collection
    }
 
    liste(){
        return $.ajax({
            url: API_CPA + 'metadata/collection',
            type: 'GET',
            context:this,
            datatype: 'json'
        })
    }
 
    select(container=''){
 
        this.container = container;
        var thisObj = this;
        this.liste().done((data) => {
 
        $(this.container).html(`<option value="${thisObj.id_collection}" disabled selected>${thisObj.nom_collection}</option>`);    
 
        let records = data.records;
 
        records.forEach((coll) => {
            const option = document.createElement('option');
            option.value = coll.id;
            option.innerText = coll.nom_collection;
 
            $(this.container).append(option);
 
        })
    })
    }
} | 
Partager