2

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?

2
  • 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 Commented Jul 11, 2012 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
    Commented Jul 11, 2012 at 21:01

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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