weixin_33695082 2013-11-18 06:51 采纳率: 0%
浏览 24

单模ajax

i have this function roadajax() which appends data to a .modal-content

$(".modal-content").append("text here");

this .modal-content is set to display:none;

then i add OnClick to element , so when i click that element it opens a modal on .modal-content and show me its content on the modal

$(document).on("click", ".element", function() {
    // remove the current active element
    $(".element").removeClass("active-element");
    // add active class on the current element
    $(this).addClass("active-element");
    curitem = $(this).attr("id");
    roadajax(); // assigns content to .modal-content
    // showing the current element modal
    $(".active-element .modal-content").modal();
});

when i click on .element event handler fires up and i see modal ! but no data what so ever so i inspected it using firebug ..

if i removed .modal() call from my event handler normal logic happens and .modal-content is populated by raodajax() but if i re-added .modal() call .. roadajax() seems to not be able to load data into .modal-content .. some kind of a race condition

i want to know how i can show my data into modal .. is there is any other way ?

  • 写回答

1条回答 默认 最新

  • weixin_33701251 2013-11-18 08:20
    关注

    You can use direct Ajax Model by placing this syntax:

    e.g.

    function roadajax() {
         // This is In-built Ajax Functionality Provide by SimpleModel
         $('.modal-content').load('http://yoursite.com/page.html').modal();
    }
    

    This will automatically Load your page inside Model.

    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办