Posts Tagged ‘Javascript

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];
  [...]

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 ;]

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 [...]

I wanted to apply a different set of css styles to a degraded non-javascript version of a page to maintain some accessibility aspects.
I wrestled for a while with the <noscript> tag but this fails to validate in the head section of a HTML/XHTML document. This wasn’t a good enough way to do things.
Eventually (with a [...]


top