tags:

views:

133

answers:

2

I want to implement a feature similar to the "Related Questions" list shown when asking a question on Stack Overflow. I like how the related questions populated when the Title is filled in.

I am using ASP.NET and jQuery. How might I implement something like this? Can anyone point to examples?

I looked at the source of the ask question page and I don't see any onblur or focus calls.

+3  A: 

As a matter of fact there is a call. This bit of code is responsible for the GET request which is sent to the server ob 'blur' of the #title input element (it's in the source of the page, close to the top):

$().ready(function() {
    $("#title").blur(function() { QuestionSuggestions(); });
});

function QuestionSuggestions() {
    var s = $("#title").val();            
    if (s.length > 2) {
        document.title = s + " - Stack Overflow";
        $("#question-suggestions").load("/search/titles?like="
+ escape(s));
    }
}
dalbaeb
A: 

I was thinking of implementing something similar, although this may not be an answer to your question, here is what I was planning to do:

  1. When a question is saved parse it and create a topic word to uniqueid (of the post) mapping and save in database indexed by word.
  2. When a new question is typed and the focus go out of the title, make an AJAX call with all the relevant words from the database and match all the similar ids that is common (so that at least two words have the same id)
  3. Populate with div that is dynamically made visible.

I am interested to know if anyone has more insight on this...

Samuel
@Samuel, did you get any update on this further, even i am trying to build the same feature, can you help me with your experience so far?
harigm