Reputation: 3502
Is it possiable to use script elements inside the tpl attiribute.What I wanna do in my senario is add some script elements inside the tpl.how can I do that.(I have buttons inside it and wanna add soem events those buttons via javascript)
here is the my code but it gives the error.
.Tpl(Html.X().XTemplate().Html(@<text
<tpl for="."><p></p>
<script>alert("bumm");</script>
<div class="thumb-wrap" id="{Ad}">
<div class="item col-xs-4 col-lg-4">
<div class="thumbnail">
<img class="group list-group-image" src="http://placehold.it/400x250/000/fff" alt="" />
<div class="caption">
<h4 class="group inner list-group-item-heading">
{Ad}</h4>
<p class="group inner list-group-item-text">
{Aciklama}</p>
<div class="row">
<div class="col-xs-12 col-md-6">
<p class="lead">
{Fiyat} TL</p>
<p class="lead urunkodu" id="urunkodu" >
{UrunKodu}</p>
</div>
<div class="col-xs-12 col-md-6">
<input type="button" class="btn btn-success" id="sepeteEkle_{ID}" value="Sepete ekle"></input>
</div>
</div>
</div>
</div>
</div>
</div>
</tpl>
<div class="x-clear"></div>
</text>))
Upvotes: 0
Views: 76
Reputation: 912
You need to elobaret more on your problem, and Regarding using script under tpl tag, That wud be valid but a bit more complex to deal with. INSTEAD use this method
Assign id attribute to your tag
<tpl id="click_event"></tpl>
Then in your external .js or in head section, you can easily grab the click events for this element by using its id
Also for button event you can use onclick attribute to trigger some function and define that js function in head or whatever
<input type="button" onClick = "triggerMyEvent();"/>
Is this what you are looking for ?? or try explaining your question to get good answer
Upvotes: 1