This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get internet explorer version | |
// returns the version (i.e 9) or false if is not IE | |
function getIEVersion() { | |
return (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) && +(/msie\s(\d+)/i.exec(navigator.userAgent)[1]); | |
} | |
// usage example | |
var ie = getIEVersion(); | |
if (ie && ie < 10) { | |
alert("This site is best viewed with IE10+"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function makes a post to a given url with the given parameters | |
* The form is created on the fly and also the input elements | |
* @path the URL path | |
* @params the URL query parameters | |
*/ | |
function postToUrl(path, params) { | |
var form = document.createElement("form"); | |
form.setAttribute("method", 'post'); | |
form.setAttribute("action", path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firstTest().then(secondTest).then(thirdTest).then(fourthTest); | |
function firstTest() { | |
var def = new $.Deferred(); | |
console.log('First test started'); | |
setTimeout(function () { | |
console.log('First test finished'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>jQuery Custum Events</title> | |
<script src="jquery.js"></script> | |
<style type="text/css"> | |
#messages{ | |
width: 200px; | |
height: 100px; | |
border: 1px solid #000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var selectvalues = { "1": "item 1", "2": "item 2", "3": "item 3"}; | |
var $dropdown = $('#dropdown'); | |
$.each(selectvalues, function(key, value) { | |
// add to dropdown | |
$dropdown | |
.append($('<option>', { value : key }) | |
.text(value)); | |
}); | |
// refresh the elements on zurb dropdown | |
Foundation.libs.forms.refresh_custom_select($dropdown, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isLeap = new Date(year, 1, 29).getMonth() == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// array with values to be added | |
selectValues = { "1": "test 1", "2": "test 2" }; | |
// for each value in the array append option to select | |
$.each(selectValues, function(key, value) { | |
$('#mySelect') | |
.append($('<option>', { value : key }) | |
.text(value)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>jQuery Custum Events</title> | |
<script src="jquery.js"></script> | |
<style type="text/css"> | |
#light{ | |
width: 100px; | |
height: 100px; | |
background-color: black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.cachedScript = function(url, options) { | |
// allow user to set any option except for dataType, cache, and url | |
options = $.extend(options || {}, { | |
dataType: "script", | |
cache: true , | |
url: url | |
}); | |
// Use $.ajax() since it is more flexible than $.getScript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Backbone Trainning</title> | |
</head> | |
<body> | |
<!-- Template --> | |
<script id="todos-tmpl" type="text/x-handlebars-template"> | |
{{#each todos}} | |
<div class='todo-item'> |
NewerOlder