Monday, February 21, 2011

Popup not working properly with jquery

We had a problem with popup.Problem was as soon as page loads if we click 'Edit' hyperlink popup was coming,but after clicking check box/button in any other custom webpart that are available on the page,after that if we click on 'Edit' link popup was not coming up.From my TL i came to know the problem as popup is getting called in document.ready function.After any post back this function doesn't get called,popup should not be called in the document.ready function.For fixing this issue i got some Knowledge by go throughing the below link
http://geekswithblogs.net/venkatx5/archive/2010/11/17/how-to-open-a-page-in-sharepoint-2010-dialog-framework.aspx
After go throughing the above link
I have added the below function in the popup.js(path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\xx\xx-js)

//User Defined Function to Open Dialog Framework
function OpenDialog(strPageURL)
{
var dialogOptions = SP.UI.$create_DialogOptions();
dialogOptions.url = strPageURL;// URL of the Page
dialogOptions.width = 750; // Width of the Dialog
dialogOptions.height = 500; // Height of the Dialog
dialogOptions.dialogReturnValueCallback = Function.createDelegate( null, CloseCallback); // Function to capture dialog closed event
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
return false;
}

// Dialog close event capture function
function CloseCallback(strReturnValue, target)
{
if (strReturnValue === SP.UI.DialogResult.OK) // Perform action on Ok.
{
alert("User clicked Ok!");
}
if (strReturnValue === SP.UI.DialogResult.cancel) // Perform action on Cancel.
{
alert( "User clicked Cancel!");
}
}
After this please change the code as below in the xxItemStyle.xsl in the template My Selection



Javascript:OpenDialog('');void('');

Recommendation to test the issue

1)Comment the code as below in the popup.js file(path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\xx\xx-js)

//$(document).ready(function () {


// $('a.poplight').each(function () {
// var href = $(this).attr('href')
// href = '#' + href.substr(href.indexOf('?'), href.length).replace(/#/, '')

// $(this).attr('href', href)


// });

//});

2)After doing above code changes please do iisreset,delete the cookies,history from Internet Options and close that browser
3)Open another browser and test the issue

No comments:

Post a Comment