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 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)