<template name="index">
<textarea id="toSpeech" type="text">Type what you want to say!</textarea>
<button>
<span><a href="#" class="btn" id="openBtn">Sounds like</a></span>
</button>
</template>
<template name="soundsLike">
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<iframe src="{{ reduced }}" style="zoom:0.60" width="99.6%" height="100%" frameborder="0"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</template>
Template.index.events({
// handle the form submission
'click .btn': function(event) {
Modal.show('soundsLike')
}
});
Template.soundsLike.onRendered(function() {
var src = $("#toSpeech").val();
var replaced = src.replace(/ /g, '+');
console.log(replaced);
});
我想通过#openBtn onclick传递textarea中的文本。我使用了Template.soundsLike.onRenderer,但是这个变量在soundsLike模态模板中不可用
答案 0 :(得分:0)
如果您使用bootstrap-3-modal
,则usage部分为您提供了一种将数据上下文传输到模式的方法:
Template.index.events({
// handle the form submission
'click .btn': function(event) {
var src = $("#toSpeech").val();
var replaced = src.replace(/ /g, '+');
Modal.show('soundsLike', {replaced: replaced});
}
});
Template.soundsLike.onRendered(function() {
console.log(this.data.replaced);
});