0

I am currently experimenting with the following script to create a pop-up form on my sharepoint 2013 site. I am addnig the code to a script editor web part...

<script type="text/javascript">


SP.SOD.executeFunc("callout.js", "Callout", function () {


var _link = document.getElementById("ContactusLink");

var listCallout = CalloutManager.createNew({ 
                launchPoint: _link,
                beakOrientation: "leftRight", 
                ID: "CallOut ID", 
                title: "Contact Us", 
                content: "<div class=\"ms-soften\" style=\"margin-top:2px; \"><hr/></div>"
+ "<div id='confirmationBLOCK' style=\"margin-top:13px;visibility:hidden;\">Thank you for Contacting Us!</div>"
+ "<div class=\"callout-section\" style=\"margin-top:2px;width:95%;Height:200px; \"><textarea id='CommentsArea' style=\"width:100%;height: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;\">Add your Comments here...</textarea></div>", 
            }); 

//Creating a Submit Custom Action
var customAction = new CalloutActionOptions();

customAction.text = 'Submit';

customAction.onClickCallback = function(event, action)
{
var _contactUsTextarea = document.getElementById('CommentsArea');

//Adding the new Contact Us Item in the List.
AddIteminList(_contactUsTextarea.value);

_contactUsTextarea.style.visibility='hidden';

};

var _newCustomAction = new CalloutAction(customAction);

listCallout.addAction(_newCustomAction);

});




function AddIteminList(_contactUsText) {

var context = new SP.ClientContext.get_current();

var web = context.get_web();

var list = web.get_lists().getByTitle('Contact Us');

var listItemCreationInfo = new SP.ListItemCreationInformation();

var newItem = list.addItem(listItemCreationInfo);

newItem.set_item('Title', _contactUsText);

newItem.update();

context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
}

function success() { 

var _confirmationblock = document.getElementById('confirmationBLOCK');

_confirmationblock.style.visibility='visible';

}

function failed(sender, args) { alert('failed to add a List Item:' + args.get_message()); }

</script>

<div id="ContactusLink" style="width:38%;">If you have any question or Concerns, please feel free to <u><span class=\"ms-commandLink\" style=\"text-align: left;font-size: 14px;\">Contact Us</span></u></div>

But my console is telling me that sp.js needs to run in order for this code to run. So here is my question...with pure javascript, how do we combine the following two lines....

sp.js wrapper around

with...

SP.SOD.executeFunc("callout.js", "Callout", function () {...}

so that both sp.js and callout.js run for this one script?

thanks

2

You could of course nest it, but there is a built in function SP.SOD.loadMultiple.

SP.SOD.loadMultiple(['sp.js', 'callout.js'], function() { });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.