Setting the screen position when visiting previous page with jQuery
The scenario This problem came while I was working on a client’s website. Take this scenario. I have a listing page (similar to a listing page from www.trademe.co.nz or www.ascent.co.nz ). They have a lot of listings. Each listing has a hyperlink going to a detail page which describes more about each listing. If you [...]
Perform ASP.NET Postback using JQuery
Came across a situation where I needed to disable the ASP.NET button using JQuery when the user clicks on the button, this is so we stop the user from clicking the button twice while the page is doing a postback. Firstly, add the following JQuery/Javascript code: <script> function autoSubmit() { <%= ClientScript.GetPostBackEventReference(btnSaveChanges, "") %>; } [...]
Max number of words in textarea using jQuery
Here is a little code snippet to set a maximum of words in a text area element. This could be turned into a jQuery function or refactored to be better reused, but there is a sample just to get you going. $(‘textarea’).keyup(function () { var wordArray = this.value.split(/[\s\.\?]+/); //Split [...]
JQuery 1.6+ attr and prop issue
I used the following code to make sure all radio buttons where unchecked and the current one was set correctly. This worked well before jQuery 1.6. $(document).ready(function() { SetUniqueRadioButton = function(current, id) { jQuery("input[type=radio]").each(function() { $(this).attr("checked", false); }); current.checked = true; }; }); Since jQuery 1.6, this code did not work and after doing some [...]
handling multiple submit buttons in one form (asp.net webforms)
I came across an issue where I had the following setup with an asp.net website: I had a master page with one main form element I had a submit button in the master page which acts as a search button across the website I had a login page that also has a submit button Naturally [...]
www.checkoutchristchurch.co.nz live!
www.checkoutchristchurch.co.nz is now live! this site loads in my personal photos of christchurch from flickr and loads in my tweets + all tweets that have the keyword “christchurch”. It uses jquery for scrolling through the thumbnails using your mouse wheel and various jquery plugins for twitter and flickr. Check it out! List of JQuer plugins [...]
Limiting the number of text in textarea using JQuery
example: <textarea id=”id” maxlength=”255″></textarea> jQuery(‘textarea[maxlength]‘).keyup(function() { var max = parseInt(jQuery(this).attr(‘maxlength’)); if (jQuery(this).val().length > max) { jQuery(this).val(jQuery(this).val().substr(0, jQuery(this).attr(‘maxlength’))); } if (jQuery(this).parent().find(‘.charsRemaining’).length > 0) jQuery(this).parent().find(‘.charsRemaining’).html(‘You have ‘ + (max – jQuery(this).val().length) + ‘ characters remaining’); else jQuery(this).parent().append(‘<div class=”charsRemaining”>You have ‘ + (max – jQuery(this).val().length) + ‘ characters remaining</div>’); });
JQuery Event Delegation
Came across a awesome way of handling events using JQuery’s event delegation methods. I have a list of A tags grouped in a table, and each A tag will call a method and pass a ID based on a value in the same column of that A tag. jQuery(“#tableId”).click(function(event) { var $target = jQuery(event.target), target [...]


