How do I install/use the backbone.js framework? [closed] - javascript

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm new to JavaScript and was wondering how you install the backbone framework so that you can use it with javascript.

JOPLOmacedo’s first comment contains the essential answer, but I’ll elaborate it a bit:
Download jquery.js from the jQuery site, underscore.js from the Underscore.js site, and
Backbone.js from the Backbone.js site. Use the “development versions” first, as this may help you in debugging. You can place the .js files in the same folder as your own test files, to keep things simple. (Later, you will find it better to place them in a separate folder.
In your HTML code, write (e.g. after all content, right before the end tag <body> if you use one:
<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script>
// Your own JavaScript code here
</script>
This should get you started. You can use e.g. the relatively simple Hello world code in the Hello Backbone.js tutorial to check that the installation is OK, before working on your own code. (The tutorial uses remotely hosted versions of the .js file, which is another possibility.)

Related

Import CSS file into Javascript file or link to HTML file? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
This post was edited and submitted for review last year and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I just joined a project and noticed that the stylesheet is imported into each page's JS file as such:
import "../../style.css";
Now, I'm used to seeing CSS stylesheets linked in HTML files as follows:
<head>
<link rel="stylesheet" href="styles.css">
</head>
The project is using Javascript/jQuery and Vite.js as an alternative to Webpack. I looked at the Vite documentation and saw that the example projects use the CSS #import, but there's no information on why that is in particular.
Is there any reason to import the stylesheet into JS files, rather than linking to the HTML files? Or vice versa? Not looking for opinions here, I'm wondering if there are best practices or advantages/disadvantages to consider with one approach or another.
It hands off the decision about when to include different bits of CSS to the bundler (e.g. webpack) instead of including every bit of CSS everywhere.
Further reading: Tree shaking CSS Modules

(Newbie) React Sandbox, .js and html files [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm complete newbie to react environment. Currently I learn basics from egghead begginers guide:
https://egghead.io/lessons/react-render-two-elements-side-by-side-with-react-fragments
https://codesandbox.io/embed/github/kentcdodds/beginners-guide-to-react/tree/codesandbox/02-react-create-element?fontsize=14&hidenavigation=1&theme=dark
In this course, Instructor programming everything in html file. But in codesandbox.io there is an option to create react sandbox with .js files
What's the difference in this approaches? Is this course deprecated in some parts? Is modern developing require .js files?
Of course, u can create a react app in one html file, but it`s much better to practice the right filing and separate the code into different files. F.e. HMTL code in HTML files, JS in JS and so on. U got my point.

What order do JavaScripts need to be written in Python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Update
Thank you Chris and Taplar for providing the following links -
www.getbootstrap.com/docs/4.5/getting-started/introduction
load and execute order of scripts
I did not look at the documentation in the first place because I did not have enough grasp of the issue, to even know what part of the documentation to search in.
Original Question
I had many issues when adding my date widget to my customer user profile model, you can see more of my code relating to the issue here. One issue was related to the order of my Java Scripts.
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.1.2/js/tempusdominus-bootstrap-4.min.js" integrity="sha256-z0oKYg6xiLq3yJGsp/LsY9XykbweQlHl42jHv2XTBz4=" crossorigin="anonymous"></script>
If I put my scripts the other way round, the date widget would not work.
It never dawned on me that the order the scripts were in would have an impact on whether the code worked or not.
Would an experienced Python programmer be able to tell, just by looking at the two scripts, what order they need to be in?
To prevent future problems, is there anything I can check, to work out what orders script need to be written in?
The libraries must be included in that order, as the bootstrap file is a plugin for the base library of jQuery. Without the base library already included, the addon has nothing that it can add-on to.

Javascript ReferenceError: $ is not defined using bootstrap framework [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
On my following website every function that related to javascript (using bootstrap framework) isn't working properly. Today when I began to work on it the application worked fine and the only thing I changed on the website that could affect the page itself / all pages that the website contains is the navigation bar that I edited when I added a simple green button, that when I delete it will not fix the error. I've been searching and testing for days and can't find the solution.
Whenever I view the error logs there is one simple error
ReferenceError: $ is not defined (index.php:110)
that refers to
<script type="text/javascript" >
$(document).ready(function() {
$('.carousel').carousel()
});
</script>
which should only affect the home page as this file is not called on any other part of the website.
However, as I don't know where to start searching in the code for this error, I can't really post the whole code here. However it can be viewed on the link above. I'm actually just searching for a position to start fixing or looking for some typos or whatever, but I got confused because it worked before I added a PHP-script which doesn't affect the websites state at all.
Any clues? Thanks for answers.
My guess is that the jquery file is not properly linked.
You have to consider that your main html has to link to the custom javascript code AND a javascript library code, wich can be hosted in your local server or somewhere in the internet.
Make sure you have something like this in the body of your Html file, and before your custom js code:
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
The jQuery library is not loaded yet - or at all.
You forgot to load the jQuery library. Be sure you load it before all your javascript code and before bootstrap library also.
You should load bootstrap after jQuery, and you should execute the code below only after you load jquery.js and bootstrap.js
$(document).ready(function() {
$('.carousel').carousel()
});
Note: Any code that has to do with $ it's linked to jQuery, so you have to use it after (not before) the jQuery library. I recommend you to use all your Javascript code just before the </body> tag

Edit external CSS/SCSS with javascript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to 'edit' a file that's already saved on my server, example:
<link rel="stylesheet" href="css/plugin.scss">
But not only that, I want to edit a certain specific line, in SASS you can define variables in css, basically, I'd like to search inside this file with JAVASCRIPT for the string:
'$increment:
And if it's found, find out what line it is on and replace that whole line with:
'$increment:10;
Basically I want to generate a downloadable file for the user that's custom depending on what settings they choose via a html input field.
If there's a simpler/better explanation I'm all ears :)
The javascript you seem to be referring to (jQuery) is a client-side language so you're not going to be able to do anything on your server with it. A js solution that could do this may be written in nodejs but you may be better served using something like Python, Rails, or even PHP.

Categories