mrkeck Sharing the Love


Multi-line Javascript

Turns out you can use a backtick (`) to write on multiple lines in javascript

This is on more
than one line



Make buttons act like buttons

By default, buttons are submits, so this should make them act actually like buttons

Filed under: HTML, jquery No Comments

Cross-Browser Testing

I'm using a Mac so no IE to play with, so it got me looking around. opens a dynamic cloud computer with whatever OS, Browser, and Resolution you would like. The remote Browser has dev tools, even Firebug Lite in IE.

You can take screenshots if you want to as well.

I used this instead of (which looks cool too, takes screenshots based on different browsers) because I needed to login to the page I was testing.


jQuery attr vs prop for Checkbox

attr is iffy

$('.checkbox').attr('checked', true);      //Doesn't work
$('.checkbox').attr('checked', 'checked'); //Sometimes works
$('.checkbox').attr('checked', false);     //Works

but prop works every time

$('.checkbox').prop('checked', true);  //Works
$('.checkbox').prop('checked', false); //Works
Filed under: HTML, jquery 1 Comment

What is being clicked?

Sometimes with onclick stuff isn't happening as expected so I do

$(document).on('click', function (e) {

which tells me what is receiving the click

Filed under: jquery No Comments

TableTools in CodeIgniter

The key is using

"sSwfPath": "<?php echo base_url(JS.'media/swf/copy_csv_xls_pdf.swf');?>"

and store the "media/swf/copy_csv_xls_pdf.swf" in the resources JS folder.

"oTableTools": {
  "sSwfPath": "<?php echo base_url(JS.'media/swf/copy_csv_xls_pdf.swf');?>",
     "aButtons": [
	  "sExtends":    "collection",
	  "sButtonText": 'Save <span class="caret" />',
	    "aButtons":    [ "csv", "xls", "pdf" ]

Select2 Width not listening to CSS

When the select2 doesn't change with the css, use $('select').select2({width:'resolve'});
resolve tells it use the css and if there isn't any then guess using javascript.


width: 500px;
<option>Some Option</option>
Filed under: jquery, select2 No Comments

jQuery Submit Function Not Working

jQuery submit function error "Property 'submit' of object # is not a function" seems to happen if you use "submit" as a name inside the form you are trying to use the submit() function on.

<form id="theFrm">
<button name="submit" type="submit">Save</button>

Don't use "submit" as a name and $("#theFrm").submit() should work

Filed under: jquery No Comments

jQuery Uppercase each

Filed under: jquery No Comments

Use Latest jQuery

<script src=""></script>
Filed under: Javascript, jquery No Comments