Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 15th, 2006, 03:53 PM
Registered User
 
Join Date: Mar 2006
Location: Bristol, CT, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sorting Tables and Safari

The Sorting Tables code borks Safari. Specifically, defining a function within a function produces a parsing error. I've tried a few ideas to make it compatible, but nothing yet. Any ideas?
Reply With Quote
  #2 (permalink)  
Old March 17th, 2006, 09:42 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Unfortunately, I don't have a Mac, so I'm unable to test this myself. What is the error message that you get?

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old March 17th, 2006, 06:03 PM
Registered User
 
Join Date: Mar 2006
Location: Bridgewater, MA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Funny I was just trying to figure this out. Thought I made a typeo or something! I tried it in Firefox on mac and it works fine, but not on Safari.

Here's the error from the javascript console if anyone can help:
Value undefined (result of expression sValue1.localeCompare) in not object

On a side note. Love the book. It has been very helpful to me.

Reply With Quote
  #4 (permalink)  
Old March 17th, 2006, 10:17 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Perhaps localeCompare isn't available in Safari? If you feel like experimenting, try this JavaScript code:
Code:
alert(String.prototype.localeCompare)
If this outputs "undefined", then that means Safari doesn't support this method. In that case, you can create it yourself:
Code:
String.prototype.localeCompare = function (sOther) {
    if (this < sOther) return -1;
    else if (this > sOther) return 1;
    else return 0;
}

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #5 (permalink)  
Old March 18th, 2006, 07:09 PM
Registered User
 
Join Date: Mar 2006
Location: Bridgewater, MA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked great. You were right the localeCompare is undefined in safari. Adding that prototype did it! Thank you!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript in safari arafat.eajaz Javascript 0 September 5th, 2008 02:06 AM
sorting tables enhancement edwards_ BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 8 August 9th, 2006 03:08 PM
Mysql Sorting results from multiple tables dcb22 SQL Language 8 October 25th, 2004 10:57 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
Safari Browser Larson HTML Code Clinic 0 February 11th, 2004 10:55 PM



All times are GMT -4. The time now is 10:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.