为什么在使用ajax调用时以角度显示多次? [英] why contend show multiple time in angular while using ajax call?

查看:29
本文介绍了为什么在使用ajax调用时以角度显示多次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的演示中有两个问题.我正在制作一个弹出窗口.我应该在点击图标时打开(这里使用星形图标).当我点击星形图标时,我可以看到我想要的弹出屏幕,但问题是当我点击另一个图标/星形图标时,它会打开另一个弹出窗口而不关闭第一个弹出窗口.我需要一次显示一个弹出窗口..

  • 1 ) 我们可以一次显示一个弹出窗口吗.它只显示一个弹出窗口一次.

    2)当我包含在我的 plunker(tooltip.js 和 pop over 插件)中时.它会显示 mouseover 事件的竞争.但是当我删除它时,它会在 click 上显示strong> 事件为什么?

这是带有脚本工具提示和 popover .display on click 的 plunker 吗?

I have two problem in my demo .I am making a pop over .I should open on icon click(here is used star icon).when i click star icon I am able to see pop up screen as I want but problem is that when I click another icon /star icon it open another pop over without closing the first one pop over.I need to display pop over one at time..

  • 1 ) can we show pop over one at one time .it show only one pop over at one time.

    2)when I include in my plunker (tooltip.js and pop over plugin).It show the contend on mouseover event .but when i remove this it show on click event why ?

Here is plunker with scripts tooltip and popover .display on click ?

http://plnkr.co/edit/OYiawflIBnpJ1PKx02LG?p=preview

here is the plunker with these plugin display on mouser over event why ? http://plnkr.co/edit/OYiawflIBnpJ1PKx02LG?p=preview

 <script src="https://dl.dropboxusercontent.com/s/a98aey2mlu0h511/bootstrap-tooltip.js"></script>
 <script src=" https://dl.dropboxusercontent.com/s/s1imyubboz1qjtl/bootstrap-popover.js?m="></script>

解决方案

Well if you are still working on the problem, following is the solution. Though I am not sure if this is the best way to do it as I'm starting with AngularJS.

var getTemplate = function(contentType, scope, element) {

    var template = $templateCache.get("templateId.html");

    $.ajax({
        type: "GET",
        url: 'pop.html',
        dataType: 'html',
        success: function(data) {
          var options = {
            content: data,
            placement: "right",
            html: true,
            date: scope.date,
        };
    $(element).popover(options);

    //FIND ALL POPOVERS AND HIDE THEM EXCEPT CURRENT ONE//
    $(element).on("show.bs.popover",function(t,e){
      $("span[mypopover]").not(this).popover('hide');
    });

  },
  error: function(data) {
    alert(data);
  }
    });

    return template;
};

Following are the lines:

$(element).on("show.bs.popover",function(t,e){
    $("span[mypopover]").not(this).popover('hide');
});

Plunker:http://plnkr.co/edit/WM0K8sdPVHSNeuIlLBim

这篇关于为什么在使用ajax调用时以角度显示多次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆