Solved

SharePoint display modal blank

Posted on 2016-10-18
2
57 Views
Last Modified: 2016-10-20
Hi All,

Using SharePoint 2010

My code below sort of works.  It brings up the form in the modal window but all the fields are always blank with no data.

Here's a piece of code
function onQuerySucceeded(sender, args) {
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();

        htmlTbl += "<tr><td><a href='#' onclick=OpenEditDialog("+oListItem.get_item('ID')+","+ oListItem.get_item('ter')+")>" + oListItem.get_item('Title') + "</a></td>"+ 
        "<td>" + oListItem.get_item('Project_x0020_Number') + "</td>" +
        "<td>" + oListItem.get_item('Project_x0020_Scope') + "</td>" +
....

function OpenEditDialog(item_title, item_id){
        var options = {
            url:"/my/personal/test/paProjects/Lists/Project%20Module%20New/Item/displayifs.aspx?List=8ce29c8c%2Deb89%2D4a0d%2D83f2%2D93559faee67c&ID=" + item_id+"ter="+item_title+",
            width: 500,
            height: 300
            };
 
        SP.UI.ModalDialog.showModalDialog(options);
    }
 

Open in new window

0
Comment
Question by:Isaac
2 Comments
 
LVL 9

Accepted Solution

by:
Karen earned 500 total points
ID: 41851505
First thing I notice is that you aren't putting quotes around what presumably are strings, you need to do something like

  htmlTbl += "<tr><td><a href='#' onclick=OpenEditDialog( ' " +oListItem.get_item('ID')+" ', ' "+ oListItem.get_item('ter')+" ' )>" + ...

I have put some unnecessary spaces in there so the single quotes show up more clearly.
Note you do not need to put the quotes around them if they are numbers (I can't tell if they are or not).

Also you look like you are passing the parameters in the wrong way around

ID then Title:
OpenEditDialog( ' " +oListItem.get_item('ID')+" ', ' "+ oListItem.get_item('ter')+" ' )>"

Title then ID:
function OpenEditDialog(item_title, item_id){
0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 41852541
Thanks!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question