I like the idea of templating. In my experience it can really clean up that messy string manipulation!
I like the idea of templating. In my experience it can really clean up that messy string manipulation! There are many solutions, for example, check out John Resig's (creator of jQuery): ejohn.org/blog/javascript-micro-templating.
Awesome link, thanks – floyd Jan 18 '10 at 21:37.
You could use the load function in jQuery; This loads the content of a page into a div like this: $('#content'). Load("content/" + this.href. Split('#')1 + ".
Html", '', checkResponse); Just make a dynamic view and you are good to go...
I could, but that brings me back to the bad old days of having a specific action/partial for each AJAX update I want to do. For a RESTful fanatic, that is very painful. I'm hoping it's not the only pragmatic solution.
– floyd Jan 18 '10 at 19:31.
I would go with creating an HTML structure that contains placeholders for the elements you'll need to update via AJAX. How much structure it applies will depend on what you're updating; if you know the number of elements you'll have ahead of time, it would be something to the effect of You then write code that references the id of each element directly, and inserts into the . InnerHTML property (or whatever syntactically more sugary way jquery has of doing same thing).
IMHO, it's not really so terrible to have to assign the contents of each element, the part that you don't want to have to sprinkle through your AJAX functions is the HTML structure itself; in your app the content is volatile anyway. However, it looks like you might have a list of an unknown number of elements, in that case it may be that you'd need to just put in a placeholder: In that case I don't really see a way to avoid building the HTML structure in the javascript calls, but a reasonable amount of decomposition of your javascript should help that: function addArticle( headline, copy, authorInfo, I ){ createDiv( "article" + I + "Headline", headline ); createDiv( "article" + I + "Copy", copy); createDiv( "article" + I + "AuthorInfo", authorInfo ); } (not working code of course, but you get the idea,).
Yeah, I'm already using placeholders where-ever possible. The more common-sense suggestion of decomposing the function themselves is helpful. Actually, I like that code so much it seems like a potential jQuery plugin...and indeed: blogs.microsoft.co.Il/blogs/basil/archive/2008/08/21/… – floyd Jan 18 '10 at 20:10.
Just happened to find exactly what I was looking for: Jaml.
This is still somewhat messy and you have to sort of include layout in your Javascript. I really like John Resig's templating in one of the other answers which very clearly (mostly) separates UI and controller. Great if Jaml works for you though :) – Jaanus Jan 22 '10 at 0:28.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.