javascript - 无法让 Simplemodal 在模态窗口中显示链接内容

标签 javascript jquery html css simplemodal

我似乎无法让模态窗口显示来自另一个链接的任何内容。我很确定我使用了正确的类将它们链接在一起。这是http://www.ericmmartin.com/projects/simplemodal_v101/给出的基本js .

jQuery(function ($) {
// Load dialog on page load
//$('#basic-modal-content').modal();

// Load dialog on click
$(' .basic').click(function (e) {
    $('#basic-modal-content').modal();

    return false;
});});

我已经把基础课放到

<li><a href="about me/about me.html" class='basic'>about me</a></li>

在外部 html 链接中(关于我)我放了一个 div id

<div id="basic-modal-content">
<p> Darrien is an industrial & product designer based from Toronto. My creative approach falls along the line of biomimicry and human-centric design. 
I've recently graduated from the University of Guelph and am currently pursuing my Masters of Industrial Design at Pratt Institute.
Feel free to contact me to just chat and don't forget to look at    some of my work. 
</p>

我已将我的代码包含在这个 zip 中 ( http://www.4shared.com/zip/LGOb7yugba/Darrien_Website_V2.html )

任何帮助将不胜感激! :)

最佳答案

您遇到以下问题:

  • 用户点击您的链接
  • 触发点击事件
  • Javascript 处理一些 ID 等于 basic-modal-content 的元素
  • 没有这个ID的元素
  • 浏览器加载关于页面

你必须做的:

  • 用户点击链接(href='#')
  • 触发点击事件
  • 使用 JQuery .load()将about页面的html内容加载到特定div中的函数
  • 调用 id 等于 basic-modal-content 的模态
  • Javascript 将照管 basic-modal-content 并找到它

关于javascript - 无法让 Simplemodal 在模态窗口中显示链接内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24112497/

相关文章:

javascript - HTML:谁负责显示/隐藏滚动条?

javascript - 有没有办法让多个 html5 filereader.onload 事件按顺序触发?

javascript - meteor 从复选框 switchChange 中检索真/假值

javascript - 未验证时模式 HTML5 验证不会阻止表单提交

Jquery:悬停/取消悬停与模糊/焦点相结合

jquery - 如何在 Ruby on Rails 中提交此 HTML 表单?

javascript - 排序json对象数据

c# - 获取错误 Error-Server tags cannot contain <% ... %> constructs

javascript - 移动到下个月时,将日期添加到 javascript 日期对象不起作用

html - html5 样板演示顶部的奇怪间距