If you ever looked at BING search and liked how they kept loading the page as you scroll down then take a look at this guy’s blog post:

http://blog.wekeroad.com/2009/11/27/paging-records-sucks–use-jquery-to-scroll-just-in-time

I wanted the same effect but within a Div. I found out an easy way to get to the bottom of the Div with this guys post:

http://yelotofu.com/2008/10/jquery-how-to-tell-if-youre-scroll-to-bottom/

I combined the two to have some pretty cool stuff going on.

Just replace Rob Conery’s scroll event code with this:

$(function() {
$('#dataContainer').scroll(
function() {
var elem = $('#dataContainer');

if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight())
{
loadMore();
}
});
});

You just need a div named #dataContainer. Everytime the user scrolls to the bottom it will call loadMore(). What I do in load more is JQuery prepend() to add rows in a table inside the div. Pretty cool all around. Sorry for the crappy wording and bad examples, it’s 3:53 A.M here, but wanted to share this.


Google recently released Closure. A JavaScript optimizer, template engine, and comprehensive library. If you want to test out the optimizer or a learn a little bit more about the API I found this site that just lets you cut and paste the code in. It’s taking advantage of the Closure API.

 

 

ClosureAPI.com


Let’s say you want to use something like :

$.GetJson(url,printResults,textStatus);

Well what if you need to send additional information to printResults() ? I’ve been coding C# to long. I vaguely remember events before delegates and I haven’t made a function pointer since freshmen year in college. I’m not actually sure if there is a way of sending extra parameters to an event like this, but my solution was just to use an anonymous function before hand.

So something like this:

$.getJSON(request, ajaxData,
function(data, textStatus) {
printResults(extraDataToSend, data, textStatus);
}
);


There is an error in the filamentgroup Date Range Picker onClose event. If you select a date that has the same start and end date, the end date does not get updated but is still set to the previous value. After digging through the code I came up with this solution. In the OnClose event, just get the start and end values like this:
$(‘.range-end’).val()
$(‘.range-start’).val()

You probably are only getting this problem if you are doing some ajax stuff, so anyone else wont’ be affected. The inputs still get updated with correct values, just not at the time this event is fired.


Understanding whe JavaScript is executed is crucial in creating the web 2.0 look and feel. JQuery greatly simplifies this. I think that people that started out there JavaScript with JQuery won’t appreciate how nice the library handles this.

Traditionally JavaScript programmer would hook most of their code in an onload event in the <body> tag of the HTML document. This would insure a way to hold off executing of the script until the DOM was finished loading. Unfortuntely this also waited for all the exeternal media on the page too load also. This resulted in not so smooth page loading, as you have to download all the images before the script and start executing.

JQuery solves this by executing the JavaScript after the DOM is finished but before the media has finished downloading, resulting in a smooth gradual evolvation of the page.


After hours of waiting for activation and much frustration I found out what my trick was too get my iPhone 3GS activated.

I used my old SIM card. It had “3G” written on it. So if you have an older phone or a different provider, this may not work for you. I’m thinking maybe if your sim CARD works AT&T doesn’t actually expect you to use the one that shipped with the phone?

Other tricks I found while trying to solve my solution were people are popping their sim in and out, and some are doing a hard reset. I guess with millions of people it goes to show that there are a lot of different things that can go wrong.

Good luck!

Also people have been having luck going to http://www.att.com/activations and activating.


AdNetworks.net got a new look and started brand new with posts. This is probably a good idea since so much of the information on there is outdated. The AdNetwork scene has evolved a lot in the last few years. Here is a link:

http://www.adnetworks.net


MVC.NET

20May09

I’ve about six weeks into an MVC.NET project. Previous to that I created a RESTful web service using some of the MVC.NET routing components, which were still in beta. This project has been a great experience. I feel like I’m doing real web development. The ASP.NET Forms even model was too detached from the real HTTP model (I realize this was by design). I still feel that there is a place for model, but it’s not for me. I try to keep this blog technical, but this change is a big milestone in my career that I wanted noted.


String.Join only works on strings. I initally thought I’d create an extension method for List<T> that would use string builder to return a built string for any type of list. I don’t think StringBuilder would help much here after thinking about it. We would still have to call ToString on all the non String objects. Here is what I think is a good solution. I don’t know if it’s the best.

var result = string.Join(“,”, myList.Select(x => x.ToString()).ToArray());


I encourage you to run a test similar to the one I pasted below. In this example, using exception handling in my casting takes hundreds of milliseconds seconds to perform 10,000 cast operations (that fail). While my other code takes a few milliseconds.

Summary: Don’t use exceptions for logic. No really, don’t.

static void Main(string[] args)
{
TimeSpan span = TimeSpan.MinValue;
DateTime now = DateTime.Now;

object num = null;

for (int x = 0; x < 1000; x++)
{
for (int y = 0; y < 10; y++)
{
int myNum;
if (num != null && num != DBNull.Value)
{
int.TryParse(num.ToString(), out myNum);
}

//try { int myNum = (int)num; } // 24 seconds
//catch { }
}
}
span = DateTime.Now – now;

Console.Write(span);
Console.Read();
}

Also, if we are in debug, this would take about 25 seconds.