'JavaScript' Category Results

RSS / Twitter Feed Reader using jQuery

Wednesday, May 30th, 2012

In this article we will build an RSS / Twitter news-feed-reader-ticker. Yeah, that’s a mouth full, but you know what I’m talking about, right? This news/RSS/Twitter ticker will query web services using jQuery and return JSON results which we will then display in a scrolling ticker. Oh, hell just click the example below and see for yourself.

Click here to view scrolling ticker

There’s probably a handful of plugins that will achieve the same result, but as you will see there’s not much code needed to do it yourself. Let’s look at the code now.

(more…)

jQuery Enlightenment Review

Thursday, January 14th, 2010

jQuery Enlightenment

Over the past month I have been reading jQuery Enlightenment by Cody Lindley. Let me say now, that if you use jQuery or are thinking about using jQuery then you should most certainly buy this book. It’s a quick read (122 pages) that includes colorized code samples, easy to follow examples and solid explanations.

Author Cody Lindley is a member of the jQuery team and explains why he wrote the book.

jQuery Enlightenment was written to express, in short-order, the concepts essential to intermediate and advanced jQuery development. Its purpose is to instill in you, the reader, practices that jQuery developers take as common knowledge. Each chapter contains concepts essential to becoming a seasoned jQuery developer.

This book is intended for three types of readers. The first is someone who has read introductory books on jQuery and is looking for the next logical step. The second type of reader is a JavaScript developer, already versed in another library, now trying to quickly learn jQuery. The third reader is myself, the author. I crafted this book to be used as my own personal reference point for jQuery concepts. This is exactly the type of book I wish every JavaScript library had available.

I would argue that this book is perfectly suitable for beginners too. It’s simply a must have jQuery book. It’s the only one you need; it will take you from beginner to competent user.

I do ASP.NET / C# web development where I build web-based software for school districts. My preferred architecture is one in which I use NO server-controls. That means no GridViews, no Repeaters, no ListViews. If fact, nothing that uses runat server will be found on the page. The page will only consist of XHTML. So there is no need for a viewstate either. We end up using jQuery a lot in this architecture. We use jQuery / Ajax to call Web services that then query the database using LINQ to SQL and pass our data back to the client where we can then populate our XHTML controls. It works great and is extremely fast and efficient. The code couldn’t be cleaner. In addition, this methodology would allow you to easily change to a PHP or Java backend and you wouldn’t have to change a single thing on the frontend. I will give a full example on this methodology another time, but the point is – you need to learn jQuery.

For more information on the jQuery Enlightenment book, including a breakdown of each chapter go here. I would recommend buying the full color book from lulu.com as it’s well designed and very handy to have on your desk.

Using jQuery with ASP.NET Controls

Thursday, August 6th, 2009

jQuery, a lightweight (only 19kb in size) JavaScript library has become my new best friend. It’s like mushrooms to Mario. Obviously I’m not alone since Microsoft is now distributing jQuery with Visual Studio (including jQuery intellisense). If you are using the new MVC framework from Microsoft then you will no doubt become familiar with the intricate workings of jQuery.

jQuery is not all that difficult to learn. The biggest thing you have to understand is all the different “selectors” that are available to you. Using selectors developers can query, in a CSS like way, for HTML elements, and then apply “commands” to them.

For example, the below JavaScript uses jQuery to find a <div> element within a page that has a CSS id of “rightSide”, and shows it and “leftSide” and hides it.

javascript

  1. $('div#rightSide').show();
  2. $('div#leftSide').hide();

As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of “datagrid1”, then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of “even” – which could be used to alternate the background color of each row:

javascript

  1. $('#datagrid1 tr:nth-child(even)').addClass('even');

This next example gets all links <a> in a specific <div> and attaches an onclick event to them:

javascript

  1. $('#navBtns a').bind('click', function(event){
  2.      event.preventDefault(); //stop the link from going to href
  3.      //do something
  4. });

Being able to traverse the DOM and locate HTML elements to attach events, behaviors, animations and CSS is priceless. But what about ASP.NET controls like the RadioButtonList, GridView, ListView, Repeater, and many others that we as developers like to bind to? How do we traverse them when they all get their ids auto-generated? That’s what we will look at now! And with jQuery it’s not that hard!

(more…)

jQuery Dropdown Menu

Tuesday, March 17th, 2009

In this short article we will use jQuery to produce this dropdown menu. Over the past six months I have been using a lot of jQuery and have fallen in love with it. For those not familiar with jQuery it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. All this and for only 19KB! How nice is that? They claim that, “jQuery will change the way that you write JavaScript.” And they are right. Companies such as Google, Dell, Bank of America, Major League Baseball, Digg, NBC, CBS, Netflix, Technorati, WordPress, Drupal, Mozilla and many others use jQuery too. Ok, that’s enough of a plug, let’s look at the code:

(more…)

Nicely-Fitting Background Images

Tuesday, June 17th, 2008

In recent thread over at the SitePoint forums, someone asked how to have any sized image fit nicely into the viewport while maintaining its aspect ratio. The assumption is that all the content can fit in the viewport and no scrollbars are needed. While CSS is wonderful and magical, it doesn’t know the sizes of images and let us play with them to pixel perfection, so we must turn to good old JavaScript to maintain aspect ratio.

(more…)

Greasing Gmail

Monday, April 21st, 2008

Greasemonkey is a wonderful thing. I enjoy the little (or sometimes not so little) challenges posed by websites that I want to modify. One of the most difficult scripts to write for is Gmail, because of its dynamic nature and its reliance on very large helpings of obfuscated JavaScript and HTML. In addition, you can’t use Firebug to debug scripts, which is a major annoyance, so alert and GM_log become one’s best debugging friends. To make writing Greasemonkey scripts a bit easier, the chaps on the Gmail team supplied an API, which one commenter describes as “truly incredible, forward thinking”. It really is quite nice.

Yesterday I decided to add a little bit of functionality to Gmail. I wanted to be able to isolate messages from a mailing list I subscribe to that nobody had replied to. This would require marking as read “conversations” or messages containing “Re:” at the start of the subject line. The obvious place to put links to do this is along with the other “selectors” above the thread list (Figure 1).

Figure 1
New selectors added

I call them “selectors” simply because Gmail has given each “link” (actually a span) a custom selector attribute. The original markup before adding the links after “Unstarred” looks like this (it isn’t nicely indented in Gmail’s code though):

[HTML]

Select:

All,
None,
Read,
Unread,
Starred,
Unstarred

[/HTML]

So, it looks pretty simple to add a couple of commas and two more spans. And it is, but how to access the containing div is what the Gmail API makes easier. This is the complete script, and we’ll start off with the main loading business and the function that handles the adding of these two new links, addlinks:

(more…)

mulberry sale spyder womens jacket cheap new balance 574 mulberry outlet cheap new balance 574 arcteryx outlet mulberry sale spyder womens jacket mulberry sale spyder womens jacket mulberry outlet mulberry outlet new balance 574

Popular Articles

Top 10 Commentators


Subscribe to this feed! Subscribe by Email!

Random Bits Podcast

Blogs Worth Reading