I have a method that is running multiple times and I'm not sure why. Since this method does a ajax call, I don't want to fetch the same data twice.
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
/** | |
* Object with hidden values | |
*/ | |
var ObjectClosure = (function(){ | |
var privateValue = "hello there!!"; | |
return { | |
getValue: function(){ | |
return privateValue; | |
}, | |
setValue: function(newValue){ |
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
config |
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
@mixin bg-image($image) { | |
// other properties | |
background-image: image-url($image); | |
// other properties | |
} | |
.myclass { | |
@include bg-image('asadas.jpg'); | |
} |
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
$(selector).bind("change", function() { | |
return $.ajax({ | |
success: function() { | |
return $(this).hide(function() { | |
return $(this).show("slow", function() { | |
return mainCallback(function() { | |
return alert("Hola Mundo"); | |
}); | |
}); | |
}); |
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
(($)-> | |
class Test | |
constructor:(@error = null)-> | |
log: -> | |
if window.log? and error is not null then console.log @error | |
select: -> | |
$elements = $("div") | |
$elements.on "click" , -> | |
### | |
En este momento @ = this es un elemento de jquery |
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
<?php | |
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass); | |
$sql = sprintf("SELECT contenido FROM barra_lateral WHERE 1 "); | |
echo '<div id="barra_lateral">'; | |
foreach($db->query($sql) as $row){ | |
echo '<div class="item">' . $row['contenido'] . '<br></div>'; |
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
/* | |
No se si en en entendí to pregunta, pero me suena a estos posibles casos | |
*/ | |
// Herencia de un objeto | |
// padre | |
var Parent = (function(){ |
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
// Quiero crear un loop que corra cada 1000 miliseconds, pero que espere a que | |
// el anterior termine | |
// incorrecto: http://g.recordit.co/p8ssRrRY27.gif | |
// correcto: http://g.recordit.co/OFFYS9Nd6F.gif | |
function doStuff(){ | |
setTimeout(function(){ | |
console.log('done doing stuff'); | |
}, 3000); | |
}; |
ES2015 it's awesome and babel.js is a great tool for compiling ES2015 into
javascript code. If you take a look at babel's documentation, you'll find out
over than 20 different ways to install babel.js from node to .NET.
One of the greatets features in ES2015 is import
and export
but you can't
use it in the browser :( right out of the box.
If you want to use modules in the browser you will need to do a trick and use
browserify
+ babelify
.
OlderNewer