Hugoware

The product of a web developer with a little too much caffeine

Simple External jQuery Templates (Update)

with 5 comments

In my previous post I made some code available that would allow you to access external templates all in the same jQuery chain. Unfortunately, I discovered a few bone-head mistakes in the code the next day while I was using it.

The new code has been uploaded and the bugs (the ones I found) have been fixed. If you have anymore feedback, please let me know.

Advertisements

Written by hugoware

January 26, 2010 at 11:09 pm

5 Responses

Subscribe to comments with RSS.

  1. Great post, love the concept, however I couldn’t get it work :-(, were did u upload the latest code?

    to here?

    http://go2.wordpress.com/?id=725X1342&site=somewebguy.wordpress.com&url=http%3A%2F%2Fwww.hugoware.net%2Ftemplate.js

    Thanks I appreciate it

    Hector Miranda

    February 25, 2010 at 3:26 am

    • Yes, it should be the same location – What is the error you are having? Are you getting exceptions or just things not appearing as expected?

      hugoware

      February 25, 2010 at 9:29 am

      • Hey Hugo, thanks for your quick response, I think there is something failing with the update command, the ajax call to get the html template get executed, but the returned object seems to be the original empty object 😦

        Maybe I’m just missing something, this is the template I’m using and the call I’m making

        Error string%%errorString%%
        Has Error%%hasError%%

        var list = $.template({
        template: “Templates/ResponseHeader.html”,
        externalData: recommendationsResponse
        }).appendTo(“#Results”);

        where recommendationsResponse is a json object

        Thanks

        Hector Miranda

        February 25, 2010 at 12:52 pm

      • “recommendationsResponse” is a JSON object or a path to some JSON on the server?

        The reason I ask is because externalData is intended for loading json content from the server while the property data is for actual JSON objects in the browser. So for example…


        $.template({
        data:{ some:"object", in:"browser" },
        template:"path/to/file.html"
        })

        … as opposed to…


        $.template({
        externalData:"path/to/external.json",
        template:"path/to/file.html"
        });

        You can send me a message on my Contact Form on my site and I can discuss it with you some more via e-mail.

        I hope this helps!

        hugoware

        February 25, 2010 at 1:02 pm

  2. oh I just noticed that the template tags are gone after posting my comment, well u get the idea right 🙂 ?

    Hector Miranda

    February 25, 2010 at 12:53 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: