Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在meteoric.show中插入模板_Javascript_Meteor_Ionic_Meteoric - Fatal编程技术网

Javascript 如何在meteoric.show中插入模板

Javascript 如何在meteoric.show中插入模板,javascript,meteor,ionic,meteoric,Javascript,Meteor,Ionic,Meteoric,我想在流星弹窗里放一张评级表。我有一个按钮来显示表单: Template.thing.events({ 'click [data-action="showReview"]': function(event, template) { IonPopup.show({ title: 'Leave a review', cssClass : '', templateURL: 'reviewPopup.html', buttons: [{

我想在流星弹窗里放一张评级表。我有一个按钮来显示表单:

Template.thing.events({
  'click [data-action="showReview"]': function(event, template) {
    IonPopup.show({
      title: 'Leave a review',
      cssClass : '',
      templateURL: 'reviewPopup.html',
      buttons: [{ 
        text: 'Cancel',
        type: 'button-default',
        onTap: function(e) {
          e.preventDefault();
        }
      }, {
        text: 'OK',
        type: 'button-positive',
        onTap: function(e) {
          return scope.data.response;
        }
      }]
    });
  }
});
理想情况下,应该将reviewpoup.html放在主体中

reviewpoup.html

<template name="reviewPopup">
    {{#if currentUser}}
        Rating: {{> rating}}
    {{/if}}  
</template>

<template name="rating">
    <div class="rateit"></div>
</template>

看起来您指的是爱奥尼亚文档-meteoric遵循爱奥尼亚约定,但不是很接近,您可以假设实现是相同的。使用meteoric的最佳方法是研究meteoric应用程序和示例

在本例中,如下所示:

// Figure out if a template or just a html string was passed
var innerTemplate = '';
if (options.templateName) {
  innerTemplate = Template[options.templateName].renderFunction().value;
} else if (options.template) {
  innerTemplate = '<span>' + options.template + '</span>';
}
//确定传递的是模板还是html字符串
var innerTemplate='';
if(options.templateName){
innerTemplate=Template[options.templateName].renderFunction().value;
}else if(options.template){
innerTemplate=''+options.template+'';
}
…因此,您似乎希望使用
模板名称:
和模板名称,而不是爱奥尼亚的
模板URL

希望有帮助

在TemplateName中指定的模板只能包含静态HTML内容,否则根本不会呈现。我使用以下变通方法动态插入实际内容:

IonPopup.show({
       title: 'notification',
       templateName: 'dummyTemplate',
        buttons: [{
          text: 'Ok',
          type: 'button-positive',
          onTap: function() {
            IonPopup.close();
            }
        }]
});

//Insert the actual template in the popup:
Blaze.render(Template.actualTemplate, $('#popupContent')[0]);
模板:

<template name="dummyTemplate">
<div id="popupContent>
</div>
</template>

<template name="actualTemplate">
Actual content
</template>


您将无法使用templateUrl实现这一点。是否有其他方法,如手动提供html或js代码?@MarkUretsky nope,手动提供html不起作用,我的意思是,如果有选项,您可以使用
http://docs.meteor.com/#/full/blaze_tohtml
@MarkUretsky据我所知,没有办法用IonPopupThanks调用JS函数来获得建议——事实上,我最终还是在发布此消息并尝试使用templateName。不幸的是,这也不起作用——而且弹出的主体甚至没有被渲染。哈哈,我想那也算是一个bug了。你可能想用这些信息更新你在gitHub上发布的问题,我会在有机会的时候看一看。我已经有了…我现在处于尴尬的境地,我不确定这是一个bug还是我只是在Meteor方面不称职…哈哈:)谢谢!
<template name="dummyTemplate">
<div id="popupContent>
</div>
</template>

<template name="actualTemplate">
Actual content
</template>