Archive for the ‘Javascript’ Category

You can stop nested elements triggering their parent element event handlers (DOM bubbling) using this handy jQuery method:
http://api.jquery.com/event.stopImmediatePropagation/
I ran into this issue whilst working on a calendar/scheduling app. Where day containing elements needed click events and their child elements needed click events too.
Love the jQuery ;]

Especially if you’re trying to match attributes and their values!
Thankfully Kooilnc, the godsend has a solution:
http://stackoverflow.com/questions/1231770/innerhtml-removes-attribute-quotes-in-internet-explorer
I’ve wrapped that up into a jQuery function here:
123456789101112131415161718192021222324$.fn.ieInnerHTML = function() {
  var zz = this.html(),
       z =
     zz.match(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|’.*?’|[^'">\s]+))?)+\s*|\s*)\/?>/g);
    if (z){
      for (var i=0;i<z.length;i++){
        var y, zSaved = z[i];
  [...]

God I hate IE…. and I really don’t often hate anything….
IE tends to cache its responses to some AJAX requests, which if you ask me is very stupid for its default behaviour.
FireFox caching is disabled by default. As always much love to the Fox.
Anyway, if you’re using jQuery.ajax() remember to pass the cache: false argument [...]

If you wanted to manipulate elements you’d added to a page with jQuery after the DOM had loaded, you used to have to specify event handlers when adding them.
jQuery v1.3 has a handy new ‘live’ method. Which basically allows you to access all elements, whether present at page load or added dynamically afterward with jQuery.
jQuery [...]

It seems that you can’t submit a form with jQuery using:
1$(’form#myform’).submit();
If you have an input in the form with the name attribute set to submit. So this doesn’t work:
1<input type="submit" name="submit" value="Press to continue" />
Change the name attribute to something else other than submit and it works fine ;]

Woo hoo! It’s possible to override CakePHP plugin views just like in Rails using the Engines plugin. Documentation on how to do it is a bit thin on the ground though.
Say you created a CakePHP plugin called ‘cms’ and you had a plugin controller called ‘pages’ inside the cms plugin. Just place the views you [...]

To reset the key values in a PHP array you can do this:
1234567891011121314151617181920212223$things = array(’a',’b',’c',’d');
unset($things[0]);
print_r($things);

#outputs
#Array
#(
#    [1] => b
#    [2] => c
#    [3] => d
#)

# Actually do the reset.
$things = array_values($things);

print_r($things);
#outputs
#Array
#(
#    [0] => b
#    [1] => c
#    [2] => d
#)

Uploaded my first site today that uses SWF Upload to handle large file uploads. The admin area of that site had basic Apache HTTP authentication via a .htaccess file.
SWF Upload failed with a 401 error after testing. It seems you can’t use this style of authentication with the current version of SWF Upload. Something to [...]


top