views:

102

answers:

1

I'm having a problem with jQuery dialog and load on a web application i'm developing.
On a search result page, on each entry i have a link that give a quick view of the result, firing a modal dialog that retrieves and show html content using jQuery load.
Everything works great and i can close and open dialogs as i want without any problem.

I would like to add a feature to this dialog with a link at the bottom of it that should trigger another jQuery load showing another little tiny part of html.

This feature works just the first time; when i close the dialog picking another one preview, first load works perfectly as usual, but clicking the link does not show anything.

This is a snippet of my code:

function preview(question_id, service){
    var jQuerydialog = jQuery('<div>loading</div>');
    jQuerydialog.dialog({
     title: 'Preview',
     modal: true,
     jQuerydialog.load('/url...','', function (responseText, textStatus, XMLHttpRequest) {
    }
   );
  return false;
}

function preview_see_more(answer_id, service){
       jQuery('#see_more').append('<div>loading </div>').load('/url....','', function (responseText, textStatus, XMLHttpRequest) {
            alert('performed!')
      }
    );
return false;
}

Adding an alert ('performed') on preview_see_more load callback, this alert is fired everytime function is called and with firebug i can see ajax call triggered with status 200.

preview function is used to load the main preview; at the bottom of the main preview there is a link pointing to preview_see_more function that should add another part of html (this actually happens just the first time a main preview is created)

Any hints?

EDIT:
here an example of search result.
Clicking on [Q], preview function is triggered.
I'm working (still on my test machine) to add a link at the bottom of the dialog that should trigger the preview_see_more function.

EDIT2:
here an example with the problem in evidence.
Click on the [Q] of the first link; then click on "show accepted answer"..close the dialog and try again.

+1  A: 

Hi, I would like to take a look at the page with preview_see_more link still on the page. What I suspect is that you binding the link to function just once and reloading the content and not binding the function next time. But it would be much more clear if you could add the link

Edit: I added this to the code and it worked.

 function quicklook_accepted_answer(answer_id, service){
 jQuery('#accepted_answer_block :last').append('<div>loading <img src="/images/indicator.gif"/></div>').load('/quicklookanswer?answer='+ answer_id +'&service='+service,'', function (responseText, textStatus, XMLHttpRequest) {
 }
 );
 return false;
 } 

But the main problem is there are many instances of modal popup being created what you can do is delete the modal box when a new 'Q' button is clicked

Kapil
@Kapil i think dialog\modal has some problem to handle jquery.I can't even use Jquery Toggle(). I opted for another solution. Thanks anyway.If you want to inspect the problem, the second link is there to test.
systempuntoout