首页 文章

使用Meteor弹出语义UI

提问于
浏览
-1

我正在尝试将Semantic's popup与流星一起使用

<a href="{{pathFor 'Movie_Info' _id=movie._id}}"><img src={{movie.HomePoster}} data-title="Title" data-content="Description"></a>


/*JS file*/
Template.Home_Page.events({

});

$('img')
    .popup({
      boundary: 'a',
    })
;

但当我将鼠标悬停在图像上时,它并没有显示弹出窗口...我做错了什么?

1 回答

  • 0

    在Blaze(Meteor的默认模板呈现引擎)中,您使用事件映射将事件附加到组件 .

    模板:

    <a href="{{pathFor 'Movie_Info' _id=movie._id}}">
      <img src={{movie.HomePoster}} class="popup-target" data-title="Title" data-content="Description">
    </a>
    

    注意,我添加了 class="popup-target" ,它将充当我们的事件监听器的选择器 .

    JS:

    Template.Home_Page.events({
      'mouseover .popup-target' (event, templateInstance) {
        // trigger popup using jquery here
        // event.currentTarget is the source of the event
        // in our case the image
        $(event.currentTarget).popup({
          boundary: 'a',
        })
      }
    });
    

    在这里阅读更多:

    http://blazejs.org/api/templates.html#Event-Maps

相关问题