I've uploaded a new release to my jQuery appendTemplate plugin over at jQuery Plugins. The new version includes:
- caching of templates
- callback function
Link:
http://plugins.jquery.com/project/appendTemplate
Friday, October 15, 2010
Tuesday, October 12, 2010
jQuery.appendTemplate(url, args[])
Appends a template from file onto an element.
url: template url
args[]: dynamic list of arguments that goes into the template
Download
url: template url
args[]: dynamic list of arguments that goes into the template
Example code:
$(document).ready(function(){
$.getJSON(
"data/data.json",
function(data){
$.each(data, function(i, item){
$("#myList").appendTemplate(
"templates/row.template",
item.url,
item.text);
});
});
});
So what does it do?
The appendTemplate function loads a template from file and fills it with the arguments you pass. Sort of like a string.format(args[]) function.
Author
Written by Anders Nygaard. Fan or hate mail: anders.nygaard at googles mail service
Download
Tuesday, October 05, 2010
On my wish list: Static extension methods
Ideally, I want to remove as much lambda expressions as possible out of my repository classes. Using Subsonic, I want to implement my own fluent methods which do not require any lambda in the implemented repository class at all.
Now, please correct me if I'm wrong, but while you can make a generic extension class you can't really make static extension methods in c#? Code would be something like this:
And implementation would be something like this:
If I find a smooth way of doing this without the use of static extension methods, I'll let you know.
Now, please correct me if I'm wrong, but while you can make a generic extension class you can't really make static extension methods in c#? Code would be something like this:
public static class GeneralExtension{
public static T ById(this T entity, int id) where T: IActiveRecord
{
return T.SingleOrDefaul(x=>x.Id == id);
}
}
And implementation would be something like this:
public class TaskRepository : IScrumblrRepository
{
public Task Get(int id)
{
return Task.ById(id);
}
}
If I find a smooth way of doing this without the use of static extension methods, I'll let you know.
Subscribe to:
Posts (Atom)