0

リーフレットと合わせてenyoを使おうと思っています。リーフレット ポップアップ内にリーフレット ボタンを配置しようとしていますが、ontap コールバックが起動しません。以下に、ボタンをインスタンス化するコードを含めました。私が間違っているかもしれないことについてのアイデアはありますか? ボタンを正しくインスタンス化していない可能性があると感じています。

余談ですが、チラシのポップアップでクリックイベントの伝播が止まる問題がありましたが、解決しました。

編集: ここに、より完全なコードと jsFiddle へのリンクがあります: http://jsfiddle.net/pwnosaurus/YPqpm/

enyo.kind({
    name: "mapContainer",
    rendered: function(){
        this.inherited(arguments);

        //Initialize the map
        this.map = L.map(this.id).setView([44.981313, -93.266569],13);
        L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            {attribution: "Map data © OpenStreetMap contributors"}
        ).addTo(this.map);

        //Initilize the marker and popup
        var mark = new L.marker([44.981014, -93.270520]).addTo(this.map);
        var popDiv = L.DomUtil.create("div");
        var pop = new L.popup();
        mark.bindPopup(pop);

        //Initilize the enyo button and control
        var ctrl = new enyo.Control({
            myHandler: function(){
                alert("The foo button was tapped");
            }
        });
        var button = new enyo.Button({
            name: "thefoobutton",
            content: "foo",
            ontap: "myHandler",
            owner: ctrl,
        });

        button.renderInto(popDiv);
        pop.setContent(popDiv);
    },

});
mapCont = new mapContainer();
mapCont.renderInto(document.body);
4

2 に答える 2

0

私の推測では、あなたは Enyo の種類ではないので、所有者を設定したくないと思います。そうでない場合は、このコードがどこにあるのか、もう少しコンテキストを提供できますか?

于 2013-06-28T14:45:25.020 に答える