ユーザー ID の QRCode を表示するテンプレートがあります。
<template name="pairDevice">
{{#with currentUser}}
<div id="qrcode"></div>
<div class="key" id="qrcodeValue" style="display: none;">{{id}}</div>
{{/with}}
</template>
レンダリングされた値とヘルパーから値を設定しようとしましたが、フィールドがまだ存在しないため、常に同じ問題$('#qrcode')
が$('#qrcodeValue')
返されます。[]
Template.pairDevice.rendered = function(){
if (!location.origin) {
location.origin = location.protocol+"//"+location.host;
}
// $('#qrcode').qrcode({width : 128, height :128 ,text : $('#qrcodeValue').html()});
};
Template.pairDevice.helpers({
'id' : function(){
var appUser =Meteor.user();
var value = location.origin + ";" + appUser._id + ";" + appUser.emails[0].address;
$('#qrcode').qrcode({width : 128, height :128 ,text : value});
return value;
}
});
Blaze がレンダリングされるのは 1 回だけであることはわかっていますが、DOM の完了後にレンダリングするにはどうすればよいですか?
ありがとう