Questions tagged [unobtrusive-javascript]

Unobtrusive JavaScript is a general approach to the use of JavaScript in web pages.

Unobtrusive JavaScript is a design approach to the use of JavaScript in web pages that emphasizes scalability, maintainability and cross-browser and cross-device compatibility.

Its main focuses are:

  • Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation
  • Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack of scalability)
  • Progressive enhancement as opposed to Graceful Degradation to support the most user agents right from the start and include additional functionality for more capable ones later
511 questions
1675
votes
23 answers

Event binding on dynamically created elements?

I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off. This happens on page ready and works just fine. The problem I have is that…
Eli
  • 97,462
  • 20
  • 76
  • 81
1383
votes
17 answers

window.onload vs $(document).ready()

What are the differences between JavaScript's window.onload and jQuery's $(document).ready() method?
Vaibhav Jain
  • 33,887
  • 46
  • 110
  • 163
78
votes
15 answers

So what if custom HTML attributes aren't valid XHTML?

I know that is the reason some people don't approve of them, but does it really matter? I think that the power that they provide, in interacting with JavaScript and storing and sending information from and to the server, outweighs the validation…
Constantine
  • 1,015
  • 1
  • 8
  • 12
78
votes
3 answers

Javascript: Module Pattern vs Constructor/Prototype pattern?

I would like to know if the module pattern or Constructor/protoType pattern is more applicable to my work. Basically I am using unobtrusive javascript -- the HTML document has a reference to the .js file. My understanding of the module…
Martin
  • 23,844
  • 55
  • 201
  • 327
61
votes
4 answers

How to check browser for touchstart support using JS/jQuery?

In an attempt to follow best practices, we're trying to use the proper JavaScript/jQuery events according to what device you are using. For example, we're building a mobile site that has an tag that will have an onclick or touch event. In the case…
Alex
  • 3,719
  • 4
  • 26
  • 25
56
votes
3 answers

Getting an uncaught error "NO_MODIFICATION_ALLOWED_ERR" for input binding

I start with this: