Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have on a home page of one application a list view webpart. When a user click on the item title, a modal dialog is displayed to display the item.

Is it possible to intercept the closing of the modal in order to perform some client side operation?

As I am not opening the modal myself, I can't set the close callback.

Any thought?

[Edit] My actual goal is to reload (with ajax) data view web part after the display of the item. What I didn't say, but that can be useful, is that I have injected a webpart in the shown dispform.Aspx. Maybe there is a way to set parent closing behavior from the dialog?

share|improve this question
    
How have you created the Modal dialogue box. I have used jQuery UI modal dialogue box and I have done some customization on the closing event. in case that is what you are looking out for –  Sudhir Kesharwani Jul 11 '12 at 19:15
    
it's the out of the box list view webpart. I click on the title field to popout the dialog. –  Steve B Jul 11 '12 at 21:01
add comment

1 Answer

up vote 2 down vote accepted

Yes this is possible using JavaScript/jQuery.

You will have to include the script in either your display form (which is displayed in the modal dialog) or in the Master Page directly.

What your script will do is it will attach your custom click event to the "Save" or "Close" button on the form. Using jQuery you can do something like this:

$("input[value='Save']").bind("click",function(){
    //Custom code for the save event.
});


$("input[value='Cancel']").bind("click",function(){
    //Custom code for the cancel event.
});

This code will look for the input HTML elements with the value as "Save" or "Cancel" and bind a click function on those form elements.

We have implemented this functionality multiple times so let me know if you need more details.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.