0

I have an issue with a piece of script I am running which is suppose to populate this modal:

<div class="modal hide fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Latest Updates!</h3>
      </div>
      <div class="modal-body">
      </div>
     <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     </div>   
    </div>  

The code is:

(function($){
    $(document).ready(function(){  
        $('a.updateNotes').on('click', function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            $(".modal-body").html('<iframe width="100%" height="100%" frameborder="0" scrolling="yes" allowtransparency="true" src="'+url+'"></iframe>');
        });
    });
})(jQuery);

The issue is that when I run that code in the console of chrome I get "undefined" yet there are no actual console errors on the code it's self. That is when the page loads the code throws no issues, but if I run it in the console I get "undefined" Can some one tell me what I am doing wrong? The link that creates this, is:

<a data-toggle="modal" class="btn btn-success" href="http://adambalan.com/aisis/aisis_update/UpdateNotes/index.html" 
data-target="#modal">
    Learn More!
</a>

If you go to that actual link, you'll see content that I should see in the box. Also will the box expand to fit the content? that is expand to a specific width then scroll for anything longer?

Jquery 1.9.latest, Twitter Bootstrap 2.3.1

Note: the reason the Jquery is wrapped in (function($){})(jQuery) is because of WordPress and how it deals with Jquery, it doesn't like the $ because of other script's it uses.

Upade Jquery version 1.9.1 is being loaded in the header of the page. Clicking the link to the source takes me to the Jquery 1.9.1 source. While the code shown above is apart of the html file it's self, how ever it is "executed" AFTER the loading of jquery 1.9.1

4

1 回答 1

0

查看页面上抛出undefined错误的源代码并检查 js 加载顺序。

jquery 核心文件可能在您的脚本之后加载。

Wordpress,尤其是插件 js 代码,可能在您的情况下,需要知道是否存在 jquery 依赖项,以便它可以在插件 js 之前加载 jquery 核心文件。

如果您无法更改 jquery 核心文件的加载顺序,请将您的 js 代码向下移动,以便在您的代码运行时可以使用 jquery。

于 2013-06-05T17:00:42.853 回答