views:

20

answers:

1

I have a page with a search bar, facets, and a list of results. I'm trying to figure out how, if the user enters a search or selects a facet (drill down list like categories), to refresh the list of results and facets.

I've messed around with templating, such as John Resig's Micro-Templating (which is very cool), but it doesn't allow me to call helper extensions, which I need to do. The only way to make it work is to massage the data on the server before sending it back. But the data is coming from solr, so it's very fast, and I'd rather not do much to it before I start rendering it.

As a quick example, here's sort of the (sudocode) layout:

<form>
    <div id="query">
        <%= Html.TextBox("q")%>
    </div>
    <div id="results"/>
    <div id="facets"/>
</form>

I'd like, if they're typing, to start displaying results every few characters or second, so just pump data into the results and facets divs... Is this possible with MVC2? Or do I just need to use js templating to populate the div html?

A: 

I ended up just splitting up the results into multiple viewresults, and calling them asynchronously through jquery, like so:

function run_search(url) {
    var search_url = url.replace('?', '/facettree?');
    $.get(search_url, function (html) {
        $('#filter').html(html);
    });
    search_url = url.replace('?', '/booksearchresults?');
    $.get(search_url, function (html) {
        $('#results-list').html(html);
    });
}

Then, facets that are clicked on go straight to this method, and a timer on the query box adds the query to the url and calls this, after a pause of half a second.

Jamie