SPLookupAddNew not opening a modal

May 19, 2011 at 1:13 PM

The add new item link keeps opening a window in a new tab instead of a modal. The strange thing is that i'm using the SPLookupAddNew in a other Sharepoint Farm and there it's working great.

May 19, 2011 at 9:52 PM


Since you mentioned a modal, can I assume that you are on SharePoint 2010? Do you have dialogs enabled on the list? (List Settings / Advanced Settings / all the way at the bottom)


May 20, 2011 at 6:48 AM


Yes I'm on Sp2010 an yes I've got dialogs enabled. Like I said got it working on another farm.

May 20, 2011 at 5:57 PM

So what is different between the two farms? Some setting, the SharePoint patch level?


May 23, 2011 at 7:47 AM


A big difference is the link.
NOT WORKING: http://sitename/Lists/ToOpenList/NewForm.aspx?Source=http://sitename/Lists/OpenFromList/NewFormCustom.aspx?RootFolder=%26IsDlg=1
WORKING: http://sitename/Lists/OpenFromList/NewForm?RootFolder=&IsDlg=1

This is the link thats SPLookupAddNew generates.

May 23, 2011 at 1:38 PM

So SPLookupAddNew is generating the first (NOT WORKING) link? The link looks OK. When you say "NOT WORKING", do you mean the link is broken or that it doesn't do what you intend?

If the function is doing what you want in one place and not the other, then we need to figure out what the difference is between the two places to figure anything out. I can't try to reproduce the issue if I don't know how to do so.


May 23, 2011 at 1:54 PM
Edited May 23, 2011 at 1:54 PM

farm 1 [working link] http://sitename/Lists/listToOpenFrom/NewForm.aspx?RootFolder=&IsDlg=1
farm 2 [not working link] http://sitename/Lists/listToOpen/NewForm.aspx?Source=http://sitename/Lists/listToOpenFrom/NewForm.aspx?RootFolder=%26IsDlg=1

[not working] means "The add new item link keeps opening a window in a new tab instead of a modal"

I'm also trying to find what the difference is between the two farms. One of the differences I saw was the difference in the generated link.

May 23, 2011 at 1:58 PM

I'm very surprised that the "working link" would be generated by SPLookupAddNew. It should always pass the source so that the user ends up back where they started.

This probably has something to do with the dialog setting for each list. (List Settings / Advanced Settings / Dialogs - bottom of the page).


May 23, 2011 at 2:17 PM

So the difference in the link isn't helping. All the lists are set to open in dialog.

This is what I did: Made a library and added both jquery libraries and added it to the masterpage:

script language="javascript" type="text/javascript" src="/development/jquery/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript" src="/development/jquery/jquery.SPServices-0.6.1.min.js"></script>

Added the next code to newForm.aspx in the PlaceHolderMain:

<script type="text/javascript">
	$(document).ready(function() {
			lookupColumn: "ListName",
			promptText: "{0} toevoegen",
			completefunc: null,
			debug: true

May 23, 2011 at 2:22 PM

I haven't tested with jQuery 1.6.1. Can you try 1.5.x? Are you using the same versions of both files in the two places?


May 23, 2011 at 3:03 PM

Was really hoping that it would fix it but it didnt help.
script language="javascript" type="text/javascript" src="/development/jquery/jquery-1.5.2.min.js "></script>
<script language="javascript" type="text/javascript" src="/development/jquery/jquery.SPServices-0.6.1.min.js"></script>

May 23, 2011 at 3:06 PM

And in both cases, the columns are lookup columns to a list, right? I'm still trying to figure out what might be different.


May 23, 2011 at 3:22 PM

I'm sorry. This is SharePoint 2010. I wasn't thinking enough about this, and I was just trying to reproduce in my environment.

Note that I have a caveat on the documentation page about using the function in 2010. The function "wants" to use the same browser window. When the dialogs are enabled, that can't happen because there is no window, it's a dialog.

If you turn off the dialogs, the function should work fine, as it does in 2007.


May 24, 2011 at 7:01 AM

You're right if you turn off the modal it wil work, but opening in a modal looks much beter. I had contact with a college and he told me altered the spservices file. He used the code from Emerson Bruce.
Doing it lik this you can open a modal within a modal.

May 24, 2011 at 12:51 PM

Great. Sounds like you are all set. I have it on my list to look at Emerson's code, but I haven't gotten to it yet.