-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
Added demo codes for AltField and AltFormat in Unix and ODBC date formats.
- Loading branch information
There are no files selected for viewing
3 comments
on commit 696fc77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was in your test right? I saw that when I added tests for clearing the AltField.
I thought that your approach was rather interesting, you ran all operations against that hidden field including test assertions and the hidden field was never actually inserted into the DOM.
I also noticed something interesting about your style of jQuery programming...
You do this,
$(ElementId)
instead of...
$("#ElementId")
Which I had no idea even worked. It's interesting that it does and I see why now, but I have never seen either of these approaches before so I enjoyed reading your code, working in it, and learning from it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only recently (about 8 months ago) learned that if a property is not found on the global object (know as window in the browser) it searches for an element with that ID on the document
(DOM).
But there's a reason you rarely see this (in fact I would never use this in an environment that I don't 100% control).
The reasons you should avoid using this is:
- If you define an element with the Id
foo
and then someone in the future defines a global calledfoo
you will have a name clash (where the global wins and your code breaks). - Even developers that know this trick will think it's a property on the global object and try to search for its definition in
.js
files before they realize it's defined in HTML. - The Id must be a valid JavaScript identifier (which is rarely the case because you can use characters such as
-
,#
or.
)
The reasons I use this trick in our unit tests are:
- I'm kind of lazy when it comes to writing well factored unit tests.
- I 100% control the test environment so when it fails I can just refactor this.
- Unlike a production like environment the whole point of unit tests are running tests and watching it fail (even on annoying things like this).
I'm not saying it's always a bad idea to use this trick, but you should definitely think twice before using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was able to pull up quite a bit of info about it, most of it read like that and most folks recommended against it. I figured you knew all of this too but I didn't want to say anything to you about it. I trust you and I know you will beat me to fixing any sort of problem that might arise. And using the hidden input without even inserting into the DOM. Thats great, I had no idea that would work as such. Very interesting approaches, this is all very rewarding stuff for me! We are a good team and this is a lot of fun! Woot!
@KidSysco Forgot to say great work with the new demo yesterday :)
It's definitely better than my example fiddle where the alternate field gets hidden when you open the menu.