Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2006, 03:53 PM
Registered User
 
Join Date: Mar 2006
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?
 
Old March 17th, 2006, 09:42 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
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/
 
Old March 17th, 2006, 06:03 PM
Registered User
 
Join Date: Mar 2006
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.

 
Old March 17th, 2006, 10:17 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
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/
 
Old March 18th, 2006, 07:09 PM
Registered User
 
Join Date: Mar 2006
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!






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





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