Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

jquery plugin works if declared in <script> tag but not in seperate .js file

Posted on 2011-10-21
3
Medium Priority
?
247 Views
Last Modified: 2012-05-12
I have a jquery plugin that works if placed in a <script> tag but does not work if placed in a seperate .js file

Is there a resolution for this?

WORKS THIS WAY:
<link href="../../Scripts/css/jquery.modaldialog.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
<script src="../../Scripts/js/jquery.modaldialog.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function ()
    {

        $.modaldialog.error('The operation failed completely.');  ////   runs just fine

    });
</script>

Open in new window




DOES NOT WORK:
<link href="../../Scripts/css/jquery.modaldialog.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
<script src="../../Scripts/js/jquery.modaldialog.js" type="text/javascript"></script>

//same code but in a .JS file this time.....
<script src="Scripts/__testmodal.js" type="text/javascript"></script>

Open in new window



Contents of __testmodal.js:
$(document).ready(function ()
{
       alert("show new modal");   //this shows up just fine

   $.modaldialog.error('The operation failed completely.');  //this does not run ... browser says modaldialog is undefined

});

Open in new window



Here is where I found the plugin:

plugin:
http://plugins.jquery.com/project/modaldialog


demos:
http://tautologistics.com/projects/jquery.modaldialog/doc/1.0.0/
0
Comment
Question by:Tom Knowlton
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 37008113
assuming your page stay at : http://www.domain.com

try to download your script with :

http://www.domain.com/Scripts/__testmodal.js

else put it in Scripts/js/ folder
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 37008182
That did it.

0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 37008184
thx
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question