Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Recommendations for JavaScript drop-down menu code

Reply
Thread Tools

Recommendations for JavaScript drop-down menu code

 
 
Richard Cornford
Guest
Posts: n/a
 
      10-28-2007
Brian Adkins wrote:
> On Oct 27, 6:28 pm, Richard Cornford wrote:
>> Brian Adkins wrote:
>> If none of these issues had ever been solved, or nobody had
>> ever managed to create a genuinely cross-browser script then
>> it certainly would by now be acceptable to always give up the
>> attempt. However, some perfect, or near perfect, solutions
>> have been demonstrated possible, so defeatism is not
>> indicated here.

>
> That's good news. Are you aware if this cross-browser
> JavaScript knowledge been consolidated and captured somewhere?


Well, obviously the necessary knowledge must be captured and
consolidated in the minds of the individuals who demonstrate the
possibilities.

>>> Every "build vs. buy" decision involves pros/cons that
>>> must be evaluated. In my case, although I enjoy the
>>> JavaScript language, I need to spend the majority of my
>>> time on server-side development, so I don't have the time
>>> to work out all the browser portability issues, etc. If a
>>> library does a "good enough" job, then it could save
>>> valuable time.

>>
>> The "saves valuable time" argument gets made from time to time,
>> but it often does not hold water because for any given library
>> there is still a need to spend time learning how to use the
>> library. And since no single library can achieve applicability
>> for all contexts without being both ridiculously bloated and
>> every over the top for most of those contexts it then becomes
>> necessary to spend time learning how to use many libraries.

>
> If the time to learn how to use a library exceeded the time
> saved by using the library, then I wouldn't consider the
> library "good enough".


Doesn't that assessment lead to a 'Catch 22' situation where you cannot
assess the time needed to learn (and so trade that off against time
saved) until you have learnt to use the library? If the results fail
your "good enough" here the time that has been spent learning the
library in order to assess how long that would take is pure wasted time.

But then there is the question of how you would know that you were done
learning any library. Obviously that is quite important to any
assessment of how log the process takes.

> I like to write my own code as much as anyone, but it's not
> always the best investment in time. Over the years, I've
> benefited by being able to reuse libraries in various
> languages, so I was a bit surprised at what seems like a
> prevalent attitude of "write it all yourself" on
> this newsgroup.


Didn't I write you a very long post explaining code re-use strategies
that are suited to browser scripting tasks? Nobody is saying 'write it
all yourself', though it is obviously a good idea to know how to write
it all yourself because without that it is impossible to judge the stuff
that comes off other people's shelves, and eventually there will be
something needed that does not currently exist at all. And the act of
learning to write it all yourself, if reasonably handled, will go a long
way to providing anyone who does so with a large collection of their own
re-useable and well-tested code.

> Do you think that comes from the constraints of using
> libraries in JavaScript, or is there another factor
> I'm missing?


You seem to be miss-characterising what you read so there probably is
something you are missing.

Richard.

 
Reply With Quote
 
 
 
 
Brian Adkins
Guest
Posts: n/a
 
      10-28-2007
On Oct 28, 1:40 pm, "Richard Cornford" <(E-Mail Removed)>
wrote:
> Brian Adkins wrote:
> > That's good news. Are you aware if this cross-browser
> > JavaScript knowledge been consolidated and captured somewhere?

>
> Well, obviously the necessary knowledge must be captured and
> consolidated in the minds of the individuals who demonstrate the
> possibilities.


If you're saying this cross-browser JavaScript knowledge is
distributed among the minds of various individuals, then I'd say it's
neither captured nor consolidated. I feel you're being purposely
obtuse here.

> ... Nobody is saying 'write it
> all yourself' ...


Ok, now I feel like we're just going in circles. Let me just be
crystal clear by asking one simple question:

Which publicly available JavaScript libraries do you feel are
worthwhile to use?

 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      10-28-2007
On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:
> On Oct 28, 1:40 pm, "Richard Cornford" <(E-Mail Removed)>
> wrote:
>
> > Brian Adkins wrote:
> > > That's good news. Are you aware if this cross-browser
> > > JavaScript knowledge been consolidated and captured somewhere?

>
> > Well, obviously the necessary knowledge must be captured and
> > consolidated in the minds of the individuals who demonstrate the
> > possibilities.

>
> If you're saying this cross-browser JavaScript knowledge is
> distributed among the minds of various individuals, then I'd say it's
> neither captured nor consolidated. I feel you're being purposely
> obtuse here.


Possession does not imply distribution.

>
> > ... Nobody is saying 'write it
> > all yourself' ...

>
> Ok, now I feel like we're just going in circles. Let me just be
> crystal clear by asking one simple question:


You are definitely going in circles.

>
> Which publicly available JavaScript libraries do you feel are
> worthwhile to use?


You are fishing for something that does not exist. There is no magic
do-everything library out there that will safely shield you from
learning JavaScript.

 
Reply With Quote
 
Peter Michaux
Guest
Posts: n/a
 
      10-29-2007
On Oct 28, 4:19 pm, David Mark <(E-Mail Removed)> wrote:
> On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:
>
> > Which publicly available JavaScript libraries do you feel are
> > worthwhile to use?

>
> You are fishing for something that does not exist. There is no magic
> do-everything library out there that will safely shield you from
> learning JavaScript.


If "publicly available JavaScript library" means something big like
Dojo, YUI, Prototype, jQuery then it does seem difficult to find a
library that will have the features appropriate to a particular task
without being bloated and be of sufficiently high quality to be
acceptable for use. It seems almost insane to write my previous
sentence because it seems such a library should exist for any
particular task. I suppose if your task is to write a modern Ajax-y
website that does normal "Web 2.0" things like everyone else and
"works" on only the newest set of browsers with images, CSS, and
JavaScript enabled for clients with fast Internet connections then you
have plenty of libraries from which to choose. You can even choose a
library API that makes you feel all warm and fuzzy inside as that is
the primary difference amongst them. If your requirements deviate even
slightly from this situation then the library pickings get slimmer.

Another option would be a JavaScript recipes book that describes many
common situations with competent solutions for at least a few
permutations of each situation so the reader would know how to make
changes for other situations without too much time investment as the
reader has learned the situation-related problems by reading the book.

In general, you would expect there were better JavaScript resources
available from which to learn or to use. The information is available
but it has not been completely aggregated in a book or code library.

The code library format Richard Cornford described where modules have
defined interfaces and several implementations for various situations
seems the most appealing. This is no surprise as this is normally the
case with Richard's suggestions. This type of library in combination
with some sort of automated build tool could be easy to use. A
publicly available library like this would be possible but it would
take detailed documentation for each implementation and would have a
steeper learning curve than the mainstream libraries available today.

Peter

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      10-29-2007
On Oct 10, 9:07 pm, Bart Van der Donck <(E-Mail Removed)> wrote:
> Thomas 'PointedEars' Lahn wrote:
> > Whether or not it [MSIE] still has a 90% market share or not (142%
> > of all Web statistics are flawed) is irrelevant

>
> As with all statistics, they are not irrelevant on condition that the
> measuring methods are acceptable.
>
> Statistically every person has one breast.


No statistics required, that is a matter of biology. All humans (and
a very large number of other animals) have two breast unless they
either have some genetic idiosyncracy or have had one or both
removed.


--
Rob

 
Reply With Quote
 
Brian Adkins
Guest
Posts: n/a
 
      10-29-2007
On Oct 28, 10:11 pm, Peter Michaux <(E-Mail Removed)> wrote:
> On Oct 28, 4:19 pm, David Mark <(E-Mail Removed)> wrote:
>
> > On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:

>
> > > Which publicly available JavaScript libraries do you feel are
> > > worthwhile to use?

>
> > You are fishing for something that does not exist. There is no magic
> > do-everything library out there that will safely shield you from
> > learning JavaScript.

>
> If "publicly available JavaScript library" means something big like
> Dojo, YUI, Prototype, jQuery ...


I'm not sure why you would think that. I simply asked about JavaScript
libraries that were both "publicly available" and "worthwhile to use".
There was nothing about size/scope in that question. It was a
straightforward question, but I still figured the likelihood of
getting a recommendation was low.

It was the guy who replied to me that invented the idea that I was
looking for a "magic do everything library" that would "shield me from
learning JavaScript" - in other words, a straw man fallacy:

http://en.wikipedia.org/wiki/Straw_man

 
Reply With Quote
 
Peter Michaux
Guest
Posts: n/a
 
      10-29-2007
On Oct 28, 9:36 pm, Brian Adkins <(E-Mail Removed)> wrote:
> On Oct 28, 10:11 pm, Peter Michaux <(E-Mail Removed)> wrote:
>
> > On Oct 28, 4:19 pm, David Mark <(E-Mail Removed)> wrote:

>
> > > On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:

>
> > > > Which publicly available JavaScript libraries do you feel are
> > > > worthwhile to use?

>
> > > You are fishing for something that does not exist. There is no magic
> > > do-everything library out there that will safely shield you from
> > > learning JavaScript.

>
> > If "publicly available JavaScript library" means something big like
> > Dojo, YUI, Prototype, jQuery ...

>
> I'm not sure why you would think that. I simply asked about JavaScript
> libraries that were both "publicly available" and "worthwhile to use".
> There was nothing about size/scope in that question. It was a
> straightforward question, but I still figured the likelihood of
> getting a recommendation was low.


You are a hard man to please, Brad. If size or scope don't matter then
it is difficult to know your motivation for asking and to give you an
answer that would be useful to you. Here is a small library you could
use that is handy for debugging

function log(msg) {
if (console && console.log) {
console.log(msg);
}
else {
alert(msg);
}
}

Watch others pick that library to shreds as I didn't test the type of
console.log to determine if it is callable. I also didn't use try-
catch for errors but that wouldn't work in NN4...etc.


> It was the guy who replied to me that invented the idea that I was
> looking for a "magic do everything library" that would "shield me from
> learning JavaScript" - in other words, a straw man fallacy:
>
> http://en.wikipedia.org/wiki/Straw_man


This thread has become confusing but as a result all sorts of bonus
information has been presented.

Peter

 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      10-29-2007
On Oct 29, 12:36 am, Brian Adkins <(E-Mail Removed)> wrote:
> On Oct 28, 10:11 pm, Peter Michaux <(E-Mail Removed)> wrote:
>
> > On Oct 28, 4:19 pm, David Mark <(E-Mail Removed)> wrote:

>
> > > On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:

>
> > > > Which publicly available JavaScript libraries do you feel are
> > > > worthwhile to use?

>
> > > You are fishing for something that does not exist. There is no magic
> > > do-everything library out there that will safely shield you from
> > > learning JavaScript.

>
> > If "publicly available JavaScript library" means something big like
> > Dojo, YUI, Prototype, jQuery ...

>
> I'm not sure why you would think that. I simply asked about JavaScript


The same reason that anybody would think that. You cited those four
earlier in the thread as "good enough" for your purposes (whatever
those may be.)

> libraries that were both "publicly available" and "worthwhile to use".
> There was nothing about size/scope in that question. It was a
> straightforward question, but I still figured the likelihood of
> getting a recommendation was low.


Your question is much too vague. "Worthwhile to use" for what? Just
what sort of "cross-browser knowledge" are you fishing for?

>
> It was the guy who replied to me that invented the idea that I was
> looking for a "magic do everything library" that would "shield me from


That sentence makes no sense, nor does the link that followed. If you
really want help, you will have to express your ideas more clearly.

 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      10-29-2007
On Oct 29, 1:05 am, Peter Michaux <(E-Mail Removed)> wrote:
> On Oct 28, 9:36 pm, Brian Adkins <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On Oct 28, 10:11 pm, Peter Michaux <(E-Mail Removed)> wrote:

>
> > > On Oct 28, 4:19 pm, David Mark <(E-Mail Removed)> wrote:

>
> > > > On Oct 28, 6:40 pm, Brian Adkins <(E-Mail Removed)> wrote:

>
> > > > > Which publicly available JavaScript libraries do you feel are
> > > > > worthwhile to use?

>
> > > > You are fishing for something that does not exist. There is no magic
> > > > do-everything library out there that will safely shield you from
> > > > learning JavaScript.

>
> > > If "publicly available JavaScript library" means something big like
> > > Dojo, YUI, Prototype, jQuery ...

>
> > I'm not sure why you would think that. I simply asked about JavaScript
> > libraries that were both "publicly available" and "worthwhile to use".
> > There was nothing about size/scope in that question. It was a
> > straightforward question, but I still figured the likelihood of
> > getting a recommendation was low.

>
> You are a hard man to please, Brad. If size or scope don't matter then
> it is difficult to know your motivation for asking and to give you an
> answer that would be useful to you. Here is a small library you could
> use that is handy for debugging
>
> function log(msg) {
> if (console && console.log) {
> console.log(msg);
> }
> else {
> alert(msg);
> }
>
> }
>
> Watch others pick that library to shreds as I didn't test the type of
> console.log to determine if it is callable. I also didn't use try-


There is no way to know for sure if the property of a host object is
callable. The best you could do is:

if (console && (typeof(console.log) == 'function' ||
typeof(console.log) == 'object')

I think your original test is adequate.

> catch for errors but that wouldn't work in NN4...etc.


Which is why you shouldn't have used try/catch, unless this function
is segregated in its own file.

It does have a few other issues though.

var global = this;
var log = (function() {
if (global.console && global.console.log) {
return function(msg) { global.console.log(msg); };
}
if (global.alert) {
return function(msg) { global.alert(msg); };
}
})();

This way you can feature test log before presenting a logging
interface.

 
Reply With Quote
 
Brian Adkins
Guest
Posts: n/a
 
      10-29-2007
On Oct 29, 1:05 am, Peter Michaux <(E-Mail Removed)> wrote:
> On Oct 28, 9:36 pm, Brian Adkins <(E-Mail Removed)> wrote:
> > On Oct 28, 10:11 pm, Peter Michaux <(E-Mail Removed)> wrote:
> > > If "publicly available JavaScript library" means something big like
> > > Dojo, YUI, Prototype, jQuery ...

>
> > I'm not sure why you would think that. I simply asked about JavaScript
> > libraries that were both "publicly available" and "worthwhile to use".
> > There was nothing about size/scope in that question. It was a
> > straightforward question, but I still figured the likelihood of
> > getting a recommendation was low.

>
> You are a hard man to please, Brad. If size or scope don't matter then
> it is difficult to know your motivation for asking and to give you an
> answer that would be useful to you.


Peter, why are you making this difficult. It was an extremely simple
question. I only presented two requirements, but you seem to struggle
with that. For example, is your "small library" below publicly
available? I expect not - so why did you present it as an example of a
worthwhile, publicly available library? The fact that I didn't specify
a scope/size doesn't mean a reasonable one isn't implied. Would you
really bother to present the code below as a "library" for others to
use? I think not, so you are just playing games here.

For example, if the same question was asked in the context of the Ruby
language instead of JavaScript, I would reply that the 'net/http'
library is both publicly available and worthwhile to use. See that
wasn't so difficult. Do you think it's an unreasonable question to ask
in the context of JavaScript?

> Here is a small library you could
> use that is handy for debugging
>
> function log(msg) {
> if (console && console.log) {
> console.log(msg);
> }
> else {
> alert(msg);
> }
>
> }


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Drop Down Menu Issue. Replacing Text of the Menu Ivann Javascript 1 07-22-2008 08:34 PM
any recommendations for drop-down menu code? laredotornado@zipmail.com Javascript 2 08-16-2006 04:40 PM
RE: Menu recommendations Yan-Hong Huang[MSFT] ASP .Net 0 07-29-2003 08:30 AM
Re: Menu recommendations Steve C. Orr, MCSD ASP .Net 1 07-29-2003 02:43 AM
Re: Menu recommendations Kevin Spencer ASP .Net 2 07-28-2003 09:29 PM



Advertisments