Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Not able to execute succeeded() & failed() functions after ModalDialogPopup's function ?

$
0
0

Hi, 

I wrote javascript for changing checkbox(IsDeleted) value from No to Yes while clicking on delete button. For that wrote the script like below. 

Here ModalDialogPopup taken for confirmation , if it is 'No' the modalpopup will close the dialog. this is fine for my script. If it is 'Yes" , it should set the checkbox value No to yes .. But here im unable to do this.

see below code. two alerts in CloseDialog() are displaying but it couldnt execute onQuerySuccedded(), the execution stops only at closeDialog().

Please help to solve this issue.   

     this.oListItem = oList.getItemById(itmID);               
     clientContext.load(oListItem,"Title", "IsDeleted");       // load items to oListItem

  var cloneModalContent = document.createElement('div');
  $("#lblConfirmationMessage").html('Do you really want to do this ?');
  cloneModalContent.innerHTML = document.getElementById('ConfirmBox').innerHTML;

   var options = {
   html: cloneModalContent, // ID of the HTML tag or HTML content to be displayed in modal dialog
    width: 375,
   height: 150,
   title: "Please Confirm",
   dialogReturnValueCallback: CloseDialog, // custom callback function
   allowMaximize: false,
   showClose: true
};

SP.UI.ModalDialog.showModalDialog(options);

    CloseDialog(DialogResult, returnValue);

 clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded),Function.createDelegate(this,this.onQueryFailed)); 

 }

  function onQuerySucceeded(sender, args) 
  {
     var lstItmTitle = null;
     lstItmTitle = oListItem.get_item("Title");   
     alert('This' + '\n' +lstItmTitle + ' has been successfully deleted!');
      window.frameElement.commitPopup();                  // Reloading parent page                
      window.frameElement.commonModalDialogClose();        // Closing the dialog

   }

   function onQueryFailed(sender, args) 
   {
    alert('Error: Could not delete item ! ' + '\n' + args.get_message() + '\n' + args.get_stackTrace());

    window.frameElement.commitPopup();                  // Reloading parent page
    window.frameElement.cancelPopUp();                   //Closing the dialog
    
   }

   function CloseDialog(DialogResult, returnValue)
   {
    if(returnValue == "Yes")
    {
      alert("hello 1");
      oListItem.set_item('IsDeleted', true);                 // set IsDeleted to true
      oListItem.update();
      alert("hello 2");
  //    window.frameElement.cancelPopUp();  
    }

   if (returnValue == "No")
   {
     window.frameElement.commonModalDialogClose(); 

   }
 
}

Thank you.





Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>