参考にさせて頂いたページ
vue.jsその0007 イベントリスニングの開始と任意のタイミングでイベントを発生させる方法 - MOTOMICHI WORKS BLOG
バージョン
Riot v2.0.15
riot-sample.htmlの記述内容
<body>
<elm-example></elm-example>
<script src="./js/core/riot+compiler.js"></script>
<script type="riot/tag" src="./js/tags/riot-sample.tag"></script>
<script>
riot.mount('elm-example');
</script>
</body>
riot-sample.tagの記述内容
<elm-example>
<button onclick={this.runHogeEvent}>runHogeEvent();</button>
<script>
this.on('mount', function() {
alert('hogeイベントのリスニングを開始します。');
this.on('hoge', function() {
//hogeイベントが発生したときに実行される処理
alert('hogeイベントが発生しました。');
});
});
runHogeEvent(e) {
//hogeイベントを発生させます
this.trigger('hoge');
}
</script>
</elm-example>
今回はここまで。