Code from codepen.io not working when downloaded: floorplan - javascript

I downloaded the code from codepen.io and it does not work locally.
http://codepen.io/nanarth/pen/raarXe
I suspect that references to some libraries are not exported, but can figure out which.
Can anyone help me with this (I am new to this)
Thank you
UPDATE: Added the following code. Still not working
<head>
<meta charset="utf-8">
<title>Floor Plan - local coordinate map layers for D3.js</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js"></script>
<script type="text/javascript" src="http://codepen.io/nanarth/pen/yyyqdL"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
Update #2: The screenshot of the error I am getting.

You're right, this pen is including external JS libs. Here's quick gif How to get there.

Those errors You got mean that jQuery libraries are not defined by the time that code runs. Ensure that:
You have copied JS code from the right pane in codepen
You have copied inline JS code from the left (html) pane in codepen
You wrap javascript in jQuery ready function

So what happens, is when then files are exported, one of the files is for some reason empty.
replacing
<script src='js/yyyqdl.js'></script>
with
<script src='http://codepen.io/nanarth/pen/yyyqdL.js'></script>
solved the issue.
Or the file can be downloaded and used locally and keep the old reference

Related

How to add jQuery CDN Link in .html?

Where should I add CDN Link in my Project? I have made a Project in Codepen, and over there It’s added in the Javascript column. But in my local machine do I have to add it in .html or .js? I have tried adding it in my <head> of .html but it’s not working.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
I have tried without "https:" and "//" as well. But still no luck.
Please let me know if I need to do anything else besides this.
If you are running the code locally, your HTML file should look like this:
<!DOCYTPE html>
<html>
<head>
<script src="url here"></script>
</head>
<body>
</body>
</html>
If that still does not work, you should put your code through the W3 Validator. You can view the errors with your HTML there.
In Codepen you need to go to settings.
Then choose JS and there you can add external libraries.
Thank you for the answers, Actually, I got the solution, I mistakenly added js/main.js instead of <script src="main.js"></script> .
And next thing I checked, I had added jQuery CDN Link in my .js file as well. I removed it from there and It worked.

AnyTime widget not working

My Anytime date picker widget is not working. Here's my reference at Site Master:
<link href="Content/anytime/anytime.5.1.2.min.css" rel="stylesheet" type="text/css" />
<script src="Scripts/anytime/anytime.5.1.2.min.js"></script>
<script src="Scripts/anytime/jquery-1.11.0.min.js"></script>
<%--<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//www.ama3.com/anytime/anytime.5.1.2.js"></script>--%>
css is working fine, but the jquery and anytime.js doesn't. As you can see I have two lines commented, those two lines work pretty well if the source is directly to their web page, but if I reference it in my local it just doesn't work, no calendar nor time picker pops up.
Anyone who knows what i'm doing wrong?
Order of loading of scripts is important when there are dependencies such as a plugin that is dependent on jQuery.js.
The dependency must load first so switch the order of your loading:
<script src="Scripts/anytime/jquery-1.11.0.min.js"></script>
<script src="Scripts/anytime/anytime.5.1.2.min.js"></script>
You should be seeing errors thrown in browser dev tools console like $ is undefined due to improper order
I just made it to work.
I tried referencing it to the page where it was called upon and I noticed a difference in the "src".
<script type="text/javascript" src="../../Scripts/anytime/jquery-1.11.0.min.js" ></script>
<script type="text/javascript" src="../../Scripts/anytime/anytime.5.1.2.min.js" ></script>
whereas if I reference it in the Site.Master, those dots doesn't exist when you click the "Pick URL". I tried pasting it back to the Site.Master with the dots and it works.

javascript not pulling through - sticky bar

I'm using this:
http://codesandnotes.com/sticky-elements/ (see the jsfiddle)
but I'm having problems in getting it to work. The pink css pulls through but it doesn't stick/doesn't change to red.
I've changed the article to an aside in the html and js. I'm using wordpress. I've added the js to the js folder and called it in the header which is pulling into the correct template. I've added the css to the main style.css. The js and css files are in different locations- could this be what's stopping the js being called?
Any help would be much appreciated. Thanks
is it fixed?
Anyway!
First add css and jQuery Library link to your WordPress Header. Then add html codes from the jsfiddle. after all the things done.
include copied js script file from the jsfiddle to the bottom of the page. See below code will help you to understand. but it's in html
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link href="copied_css_file_from_the_jsfiddle.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script><!-- jQuery Library -->
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script><!-- jQuery Library -->
</head>
<body>
<p>This is the proper way <small>How to use css js and html in correct way</small></p>
<!-- add the html code from the JSFIDDLE-->
<script type="text/javascript">
$( document ).ready(function() {
//Copy and paste the script from the JSFIDDLE
});
</script>
</body>
Contact me by searching yeshansachithak in any social network. Thanks

Windows store app - jQuery error

I'm trying to import jQuery into blank javascript app, but keep getting same error: JavaScript runtime error: 'jQuery' is undefined. I don know the reason for this.
My whole procedure:
Create new Blank app project
Add existing item jquery-1.8.2-win8-1.0 in js folder
Drag and drop added item into default.html head
Add some jquery code in default.js
and now, i'm getting this error: JavaScript runtime error: '$' is undefined.
But if I delete added jQuery code(didn't notice before) it throw's me another error:JavaScript critical error at line 4, column 1 in ms-appx://8cce31f0-7793-41f7-875e-c41dd9ade2c7/js/jquery-1.8.2-win8-1.0.js.
I'm trying to get jquery to work for last several hours, but without success.
HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jquery</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
<!-- jquery references -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
<script src="js/jquery-1.8.2-win8-1.0.js"></script>
</head>
<body>
<p>Content goes here</p>
</body>
</html>
jQuery code:
$("*").on("click", function () { });
Error's:
Video:
Error - jQuery
First of all, thank you for the video - this would have been nearly impossible to solve without it.
I noticed your jQuery file was 2.0mb; this didn't look right. And then the error message took us into its contents to point out a syntax error, where we saw a slew of HTML tags — you appear to have downloaded from the GitHub viewer page, rather than from the source file itself. You should instead download the RAW file.
Please note also that this is an older version of jQuery, and not a fully-supported version. I am the primary developer behind the appendTo repo, and am excited to announce that jQuery 2.0 (pre-release builds available) should work really well on its own in a Windows Store App.
I wrote about this recently over on nettuts: Building Windows Store Applications With jQuery 2.0
Try to put:
<script src="js/jquery-1.8.2-win8-1.0.js"></script>
after:
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
This error is probably because you're not include jQuery library before writting jQuery code and make sure the path to your file is correct
Try rearranging the scripts you added. Include jQuery js file before your default.js file. Something like this:
<script src="js/jquery-1.8.2-win8-1.0.js"></script>
<script src="/js/default.js"></script>
Default.js tries to use jQuery which is not yet added. So rearranging might help.

Updating vsDoc to 1.5 breaks all javascript

I'm having some difficulty with what seems to be the simplest of operations.
In visual studio, when I change vsDoc from 1.4.1 to 1.5, javascript on the page no longer works. (Visual Studio 2010)
The original (that works) is like this:
<head runat="server">
<title></title>
<link type="text/css" href="css/excite-bike/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<script src="Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
And everything is fine, intellisense is fine, javascript is fine. Everything is good to go.
However, when I reference the newer vsDoc file (obtained from ajax.aspnetcdn.com )
<head runat="server">
<title></title>
<link type="text/css" href="css/excite-bike/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<script src="Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.5-vsdoc.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
The page doesn't load properly and firebug shows the following errors:
class2type is not defined
rootjQuery is not defined
Both errors are apparently stemming from the vsdoc file line 67
I feel like I'm missing something terribly obvious and I hope someone can fill me in.
Thanks!
The -vsdoc is not intended to be included in your actual page, just in the files you need intellisense in. For your use, just rename:
Scripts/jquery-1.5-vsdoc.js
to
Scripts/jquery-1.5.1-vsdoc.js
and then remove that -vsdoc.js <script> block from the page. Visual studio will automatically search for the -vsdoc.js of any local JavaScript file you're including default. It need not be included in the page explicitly...that'll actually lead to issues like you're seeing, since it defines the same empty functions (and not all the needed variables).

Categories