Monaca Onsen UI Discord Chat Github Repo

[Solved] Uncaught TypeError: ons.compile is not a function

  • I have error on migrate my application to ons2(2.0.0 pre5) with this code

    function addElement (data){
    var el = "<ons-list ></ons-list>".toDOM(); // toDOM convert String to DOM element
        var li = '<ons-list-item onclick="api.execProg(this.config);">\
            <ons-ripple lo></ons-ripple>\
            <ons-icon rel="icon" icon="dot-circle-o" size="20px"></ons-icon>\
            <span rel="title">Make a Call</span>\
        for(var i in data.items){
            var e = li.toDOM();
            e.querySelector('[rel="title"]').innerText = data.items[i].title;
            e.querySelector('[rel="icon"]').setAttribute("icon",data.items[i].icon || 'dot-circle-o');
            e.querySelector("ons-list-item").config = JSON.stringify(data.items[i]);
        ons.compile(this) ; //Uncaught TypeError: ons.compile is not a function
    // Usage Ex. :'#myRoot'),{title:"Mon titre",icon:"circle",extra: "cool"})

    Error : Compile is not defined.

  • Do you have the above code called in an ons.ready() or is it how it is? While I am not an Angular expert, I believe compile is called in that function as documeted here:

  • @badlee You don’t need to run ons.compile in Onsen UI 2.0. The elements are Custom Elements and will automatically be compiled.

  • @argelius Even better! Its not used at all. lol.

  • @argelius it’s done, thank’s.