Sunday, September 11, 2011
JavaScript MVC + ASP.NET MVC
Wednesday, November 10, 2010
JavaScript gotcha
Saturday, October 30, 2010
Cross domain XMLHttpRequest
Thursday, October 21, 2010
Concatenating, Minifying and Optimizing JavaScript
2) Compress the files: YUI Compressor is the best choice. For it to work correctly I had to use the --charset flag.
Friday, October 8, 2010
Maintainable JavaScript
Friday, October 1, 2010
ExtJS combo doesn't allow empty text
So next time you use emptyText, make sure none of the items in your data store use an ID=0.
Thursday, September 30, 2010
JavaScript Unit Testing
I have still yet to find a way to call YUI test from a Continuous Integration environment. The default way to call it is by running the website to be tested, but there should be a way to call it remotely and make sure the test passed.
Friday, September 10, 2010
esri.layers.FeatureLayer is not a constructor
Al the API examples show that dojo.addOnLoad should be used but I was using Ext.onReady (another JS API). This was causing the problem because when Ext.onReady was executed the AGS JS API was not loaded. I had to use dojo.addOnLoad to make sure that when I call esri.layers.FeatureLayer it is actually loaded.
Monday, September 6, 2010
JavaScript MVC
One of the problems with the article below is that the View knows about the Controller and the Model, when it should only know about the Model. Although there is at least another problem (hint: the controller doesn't know about the View), it is very easy to fix and you get a perfect implementation of JavaScript MVC.
I am doing this with ExtJS, I'll post some code after I get it to work.
Monday, October 12, 2009
Cross domain HTTP Request using JavaScript
My first choice was to use JQuery. You can use jQuery.ajax with dataType="jsonp". However, this won't work unless the servers supports jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/). Cross domain HTTP requests are a really interesting topic.
After several tries, I decided to do this using ASP.NET (in the code-behind page):
Uri uri = new Uri("http://192.168.0.1/default/query");
if (uri.Scheme == Uri.UriSchemeHttp)
{
WebRequest request = HttpWebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();
}
Saturday, September 12, 2009
JayRock vs AjaxPro
Personally, I prefer AjaxPro. It gives you the flexibility of passing a dataset, and it also provides you a cleaner way to wrap the data you want to pass around. Check out AjaxPro here.