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
$(function() { | |
$.fn.sortList = function() { | |
var mylist = $(this); | |
var listitems = $('li', mylist).get(); | |
listitems.sort(function(a, b) { | |
var compA = $(a).text().toUpperCase(); | |
var compB = $(b).text().toUpperCase(); | |
return (compA < compB) ? -1 : 1; | |
}); | |
$.each(listitems, function(i, itm) { |
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
function($) { | |
$.fn.extend( { | |
limiter: function(limit, elem) { | |
$(this).on("keyup focus", function() { | |
setCount(this, elem); | |
}); | |
function setCount(src, elem) { | |
var chars = src.value.length; | |
if (chars > limit) { | |
src.value = src.value.substr(0, limit); |
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
function validateDate($date, $format = 'Y-m-d H:i:s') | |
{ | |
$d = DateTime::createFromFormat($format, $date); | |
return $d && $d->format($format) == $date; | |
} | |
var_dump(validateDate('2012-02-28 12:12:12')); # true | |
var_dump(validateDate('2012-02-30 12:12:12')); # false | |
var_dump(validateDate('2012-02-28', 'Y-m-d')); # true | |
var_dump(validateDate('28/02/2012', 'd/m/Y')); # 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
echo "\xEF\xBB\xBF"; // UTF-8 BOM |
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
<a href="" id="csv-export">export</a> | |
<iframe id="downloadIframe" src="" style="height: 0px; width: 0px; display: none;"></iframe> | |
<script> | |
$("#csv-export").click(function(e){ | |
e.preventDefault(); | |
oIFrm = document.getElementById('downloadIframe'); | |
oIFrm.src = '' // URL to download file -- via php download headers; | |
}); | |
</script> |
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
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="js/jquery-1.11.0.min.js" type="text/javascript"><\/script>')</script> |
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
$.ajax({ ... }).then(successHandler, failureHandler); | |
// OR | |
var jqxhr = $.ajax({ ... }); | |
jqxhr.done(successHandler); | |
jqxhr.fail(failureHandler); |
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 jqxhr = $.ajax({ | |
url: url, | |
type: "GET", // default is GET but you can use other verbs based on your needs. | |
cache: true, // default is true, but false for dataType 'script' and 'jsonp', so set it on need basis. | |
data: {}, // add your request parameters in the data object. | |
dataType: "json", // specify the dataType for future reference | |
jsonp: "callback", // only specify this to match the name of callback parameter your API is expecting for JSONP requests. | |
statusCode: { // if you want to handle specific error codes, use the status code mapping settings. | |
404: handler404, | |
500: handler500 |
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
$("#myLink") | |
.addClass("bold") | |
.on("click", myClickHandler) | |
.on("mouseover", myMouseOverHandler) | |
.show(); |
OlderNewer