燃えさしのImスターター。attritube "name"のリンクがたくさんありますが、そのうちの1つをクリックすると、この属性を取得したいと思います。私は1つとbindAttrだけを操作する方法を知っていますが、さらにこのコードを試してみましたが、機能していません。すべてのリンクに多くのbindAttr???を使用する必要がありますか?昨日これを作成しました(1つのリンクのみ):
<body>
<div id="templateHere"></div>
<!--handlebar-->
<script type="text/x-handlebars" data-template-name="text">
<h1>Send the message:</h1>
<a {{action "clicked" on="click"}} name='link1'>Click me!!</a>
<a {{action "clicked" on="click"}} name='link2'>click me again</a>
</script>
<script>
//namespace
App = Ember.Application.create();
//define view
App.myview = Ember.View.extend({
templateName: 'text',
name_attribute:'name_buttooooon',
message: '',
clicked: function(event) {
console.log(jQuery(this).attr('name'));//get attribute name value
}
});
//create view
App.myview=App.myview.create();
//insert view in body
$(function() {
App.myview.append('#templateHere');
});
</script>
</body>