Yea, I can't speak to number 3, but reading up on how 1.3 deals with
events would be helpful there. As for #2, I don't know what standards
they're recommending you play to, but I ALWAYS hide from the CSS
instead of the javascript. The reason is twofold:

#1: So if there is no javascript enabled, then they don't get to see
anything but the layout.
#2: A good 80% of my content comes in via ajax, so if JS is disabled,
they're going to have a tough time viewing the rest of my site.
#3: Who tools around with JS disabled anymore? Are there honestly a
group of people who do? Are these the same people who still have
cookies turned off and expect the internet to do interesting things?
Honestly, spending an extra hour and a half of dev time in a massive
project to make the site kind-of-work for people without jS is a waste
of time.

On Jan 29, 7:46 am, donb <falconwatc...@comcast.net> wrote:
> Check out 'event delegation' and/or the new v1.3 event handling
> features.
>
> On Jan 29, 1:25 am, B <bilalallaw...@gmail.com> wrote:
>
> > I have read a lot of articles about separating javascript from markup
> > and jQuery encourages the practice of unobtrusive javascript. Even
> > though jQuery makes it extremely easy to implement event binding, I
> > have a few questions which I was hoping you could help me with.
>
> > 1) When you bind elements on document.ready(), isn't that more
> > inefficient than using the onclick() etc function available inside the
> > markup.  When you bind the events on document.ready() you have to
> > traverse the DOM to locate each element to bind the event to adding
> > extra over head. I am working on a website which currently has around
> > a 100 different events on a page, and normally I just use the onclick,
> > onmouseover function available in the <a href> markup to define these
> > event while passing $(this) as a parameter, giving me access to the
> > caller and preventing the extra work needed to bind the events.
> > Example <a href="#" onclick="myFunction($(this))">my function call </
> > a>. Am I wrong in my reasoning that this is more efficient than
> > binding on document.ready() ?
>
> > 2) Also if you had an extremely long page and you bound events on
> > document.ready() wouldn't there be instances where the javascript
> > would not be immediately available while the page is loading? I have
> > read that it is recommended when using hidden text or hidden areas to
> > not set the display:none inside the css, but instead use a javascript
> > function call on document.ready() to hide them. This has the advantage
> > of preventing the text to be hidden for users who have javascript
> > disabled. Wouldnt this again have the issue of the hidden text
> > flashing on the screen?
>
> > 3) Currently I am using JSPs in which i sometimes come across the
> > following senario. There is a link for "write a review". If a user is
> > logged in it opens a review box, if the user is not logged in, it
> > opens a login form. The login for which action will be triggered
> > onclick is handled via the JSP tags.
> > <c:if test="loggedIn"> <a href="#" onclick="login()">review</a></c:if>
> > <c:if test="notLoggedIn"> <a href="#" onclick="writeReview()">review</
> > a></c:if>
> > If I move to unobtrusive javascript, what would be the best way to
> > handle scenarios like this?
>
> > Thank you for your time. I would really appreciate any insight you may
> > have, I really want to move to unobtrusive javascript, but the above
> > issues make me reconsider it everytime
>
> > Thanks :)

Reply via email to