Skip to content

Instantly share code, notes, and snippets.

@RedSoxFan22
Created June 17, 2015 16:11
Show Gist options
  • Save RedSoxFan22/a8dee03d50bf76ca54bb to your computer and use it in GitHub Desktop.
Save RedSoxFan22/a8dee03d50bf76ca54bb to your computer and use it in GitHub Desktop.
What is a partial?
pieces of code in Views that are called upon in different places. its like a method for the views.
<%= render partial: "partial file name", locals:{parameters} %>
in JS, : goes inside of the "" like in "getShow('hoops');"
why code in the <script> tags on the html page?
control flow on a webpage.
when the application.js runs, there is nothing on the page. this isn't request/response like Ruby, it is event driven. the point in time in which events happen, matters. JS loads when the page loads
onclick is an html code.
important to undestand the control flow because it determines if/when things get loaded
addEventListener()
when something is "getElementsByClassName('bob')", you can't call div.style.color on it because it is returning an array, and you can't call .style.color on an array. (elementS = plural = array) you need a loop to get through it.
for (i=0; i<div.length; i++) {div[i].style.color = "blue"}
"#" will keep you on the page. an alternative to that is "javascript:void(0);"
you can add id to things that don't have them and then write functions based on that. ??!!! That would have been nice to know.
fucntion onlyOnce() {
document.getElementById("finalButton") = event.target. the thing that got clicked on. $(event.target) jquery version
JQuery 11:05
instead fo document.getby.... $
$("css_selector") $("#name_field"); saying id with a # just css
$(".copyable"); saying class with a . Just like in css
$(".copyable").css("color", "blue")
if you want to set the css specifics, use two parameters after .css. like .css("font-size", "50px").
if you leave off the second parameter, it returns the value of the first. like saying, "what is your font size?"
.filter
.closest instead of parent().parent().parent()
if we pass it a function, it runs it when the page loads. $(smoothScroll)
jquery function on. .on(behavior you want it to bind to, what you want it to do)
building a modal. bootstrap 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment