Link to home
Start Free TrialLog in
Avatar of Adam Ehrenworth
Adam EhrenworthFlag for United States of America

asked on

SharePoint 2007 modal dialog pop up for NewForm not working

I am trying to get a modal dialog to pop up that displays the NewForm for a SharePoint 2007 List.

I am using the following code:

$( document ).ready(function() {
function openInModalDialog()
{
  var url = "http://itsusmpw00799:56789/prd/hcctesting/Lists/PharmSLT_Meetings/NewForm.aspx";
  commonShowModalDialog(url,"resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:800px; dialogHeight:500px;",RetrieveItemValue);
}
});

$(document).ready(function(){
   $("#add_meeting").click(function(event){
     openInModalDialog();
   });
 });

Open in new window


in addtion, the aspx page with the link has the following code:

<div class="container">
<table cellpadding="10">
<tr height="50"><td></td></tr>
<tr><td>
<b>Select Meeting:</b><br>
<select></select>
</td>
<td valign="middle">
<a id="add_meeting">Add Meeting</a>
</td
</tr>
</table>
</div>

Open in new window


I am getting an Object expected error. Any suggestions to get this to load properly? I think I have all the correct script references.
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,
two comments on this:
1. Remove the function outside of the document.ready event
I would move the function outside and therefore remove the complete first document.ready handler. Second I would add the preventDefault on the a click:
function openInModalDialog()
{
	var url = "http://itsusmpw00799:56789/prd/hcctesting/Lists/PharmSLT_Meetings/NewForm.aspx";
	commonShowModalDialog(url,"resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:800px; dialogHeight:500px;",RetrieveItemValue);
}

$(document).ready(function(){
	$("#add_meeting").click(function(event){
		event.preventDefault();
		openInModalDialog();
	});
});

Open in new window


2. Question on the internal function
How does the function commonShowModalDialog look alike and what is the third parameter RetrieveItemValue?

HTH
Rainer
Avatar of Adam Ehrenworth

ASKER

Thank you for providing those changes... I am not sure I am clear on what you mean by "look alike" and the ReturnItemValue was in other code I found online.. it may not be necessary.

I am basically trying to get the New Form for a list and for a Document Library to appear in the dialog window.

Appreciate the assistance.

The current code you provided is getting the following error

openInModalDialog is not defined
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Additional note:
I stored the above code in one text file, named this "ContentDemo.html" and uploaded the file to a document library in SharePoint. Then I added a content editor web part to another page and instead of pasting the code directly I just set the link to the previous uploaded HTML file.
Thank you! I figured out my error almost right after and your code is definitely cleaner.

One important follow up that I have not been able to successfully search for..

Where and what code on the custom aspx page do I need to include to have the modal dialog box close if the use either enters enters info and selects OK or if they hit Cancel?

Adam
Hi Adam,
could you please do me a favour? If the provided code did solve your issue, please mark the answer as solution and close this question. For your follow up question please create a new question and reference this one - and I will in the meantime work on a solution.
Thanks and KR
Rainer
Hi Adam,
thank you very much. I am working on the dialog close question - but thats a tricky one :-(
I understand. Any help you can provide is great.