Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The buttons need data

The problem with the YouCube buttons is that they are only applicable when blog data is available. And since the blog data is now loaded from an external XML file, there will be a period of time, usually very brief, where the page has no data. During this period, the buttons make no sense at all and are only confusing users.

image with no caption

Disabling the buttons is an excellent solution.

Disabling the buttons while the blog data is loading is a simple and elegant way to solve the button problem. Since the Ajax request to load the blog data is issued when the page first loads, the buttons can start out disabled and can be enabled in the handleRequest() function, which is when we know the Ajax request has finished.

To actually carry out the disabling, we need to use the disabled attribute of the <input> tag. This tag must be set to "disabled" in HTML code to disable a button. Conversely, it must be set to false in JavaScript code to enable a button element.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial