Message from JavaScript discussions

July 2017

— Wait, gonna post my full function

— 

function loadproduk(){

    $.ajax({

    type: "GET",

  url: 'http://localhost/program/public/getjson/produk',

    dataType: "JSON",

    timeout: 10000,

    

    cache: false,

    success: function(result){

        var page = event.target;

        $.each(result[0], function(index, el){

            var nama = el.nama;

            $('#datalist').append('<ons-list-item modifier="chevron" tappable ripple class="tombolmenu" onclick="bukapaket(' + el.id + ',' + el.nama + ')"><p>'+ el.nama +'</p></ons-list-item>');

            $('#prosesloadingproduk').hide();

            console.log(el.nama);

            console.log(el.id);

        });

    },

        error: function(xhr, textStatus, thrownError) {

            $('#prosesloadingproduk').hide();

            $('#dialogerror').show();

            $("#pesanerror1").html("Terjadi Masalah, Silahkan Periksa Kembali Koneksi Internet Anda.");

            $("#pesanerror2").html(xhr.error);

            $("#pesanerror3").html("");

            console.log("error,",xhr.error);

        }

    });

};

— This is TRGWII

— Christ

— Don't use onclick

— TRGWII then what do u suggest me to do? im newbie in this things 😅

— Use jQuery events instead

— .click()

— Urgh

— Is it will be like this ? TRGWII

— 

$('#datalist').append('<ons-list-item modifier="chevron" tappable ripple class="tombolmenu"><p>'+ el.nama +'</p></ons-list-item>');

$('#datalist').click(

    function bukapaket() {

    document.querySelector('#coreNavigator').pushPage('harga.html');

    document.getElementsByClassName('.judulhalaman').innerHTML = el.nama;

});

?

Message permanent page

— Because it doesnt work :/ it will trigger every menu