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 streamingtool
  • ¥15 MATLAB图像问题
  • ¥20 树莓派5做人脸情感识别与反馈系统
  • ¥15 selenium 控制 chrome-for-testing 在 Linux 环境下报错 SessionNotCreatedException
  • ¥15 使用pyodbc操作SQL数据库
  • ¥15 MATLAB实现下列
  • ¥30 mininet可视化打不开.mn文件
  • ¥50 C# 全屏打开Edge浏览器
  • ¥80 WEBPACK性能优化
  • ¥30 python拟合回归分析