I am new to the Sharepoint 2010. I have basic understanding but not sure about the coding part in SP2010.
I have one contact list and I have one button on different page.
I want when I click on that button, new pop-up window should appear contains that only contact list and on window there should a close button too.
I have sharepoint designer also and heard that it's possible through JS coding but not sure how to do this and where to add JS coding into the SP 2010 or SP designer 2010.
You could use SP.UI.ModalDialog.showModalDialog for this requirement.
Sample script.
<script type="text/javascript">
function OpenDialog(dialogUrl, dialogTitle) {
var options = {
// define a URL (and yes, you can pass params to that URL) or reference your HTML object, but NOT both!
url: '/Lists/SourceList/EditForm.aspx?ID=1&IsDlg=1',
tite: 'Modal Title',
allowMaximize: false,
showClose: true,
width: 430,
height: 230,
dialogReturnValueCallback: myCallbackFunction
};
SP.UI.ModalDialog.showModalDialog(options);
}
function myCallbackFunction(result) {
switch (result) {
case SP.UI.DialogResult.OK:
alert("You clicked OK");
// reload data as necessary here
break;
case SP.UI.DialogResult.cancel:
alert("You clicked cancel or close.");
break;
}
}
</script>
Show Modal Dialog
Related
I am using the app creator and trying to react to close tab window event using the code below.
I then preview the app in a separate window, but when I close the tab I don't get the confirmation pop up.
When I inject this code in the js console it works as expected.
Doesn't cloudfare app support such functionality?
window.onbeforeunload = function (e) {
// Your logic to prepare for 'Stay on this Page' goes here
return "Please click 'Stay on this Page' and we will give you candy";
};
I tested this and was able to see the pop up when after clicking to close the tab. Are you certain that this assignment is happening? In the previewed window, what is the output of window.onbeforeunload?
You also need to make sure to set the returnValueof e to something other than null e.g. :
function sendAlert() {
window.onbeforeunload = (e) => {
const dialogText = 'Random Text';
e.returnValue = dialogText;
return dialogText; }
}
I am looking for a way to display an on-demand pop in a Crossrider extension, in the same fassion as the Javascript 'confirm' dialog. I have an HTML page in the resources and I would like to use it in a popup, which will be displayed whenever a certain message is dispatched. I realize there is functionality to display popups in Crossrider (appAPI.browserAction.setPopup), however I would like to display a custom popup on-demand, instead of a simple JS 'confirm' dialog. Is there a way of doing that? Thank you.
You can use a combination of appAPI.browserAction.setPopup and appAPI.browserAction.clearPopup to control the popup. In the following example, the extension scope code determines which popup is required based on the page visited and sets it accordingly:
extension.js:
appAPI.ready(function($) {
if (appAPI.isMatchPages("*google", "*msn")) {
// Send message to background to set the popup based on the page url
appAPI.message.toBackground({
request: 'set-popup',
popup: (location.hostname.indexOf('google') !== -1)
? 'google.html'
: 'msn.html'
});
} else {
// Send message to background to clear the popup for other pages
appAPI.message.toBackground({
request: 'clear-popup'
});
}
});
background.js:
appAPI.ready(function($) {
appAPI.browserAction.setResourceIcon('icon.jpg');
appAPI.message.addListener(function(msg) {
switch(msg.request) {
case 'set-popup':
// When setting the page, first clear the existing popup
appAPI.browserAction.clearPopup();
// then set the new popup
appAPI.browserAction.setPopup({
resourcePath: msg.popup,
width: 300,
height: 200
});
break;
case 'clear-popup':
appAPI.browserAction.clearPopup();
break;
}
});
});
[Disclosure: I am a Crossrider employee]
i am just trying to implement facebook and twitter in my Webworks App and cannot get them work together.
I am using the FaceBook-OAuth-2 and the Twitter-OAuth-1 sample and i just put both stuff together and my problem is that only the first startOAuth() opens a window in the app to login the second doesn't so if i first clicked facebook it works after when i try twitter nothing happens.
https://github.com/blackberry/BB10-WebWorks-Samples
thanks
function setClickHandlers() {
console.log('set click handlers');
var fb = document.getElementById('facebookOn');
fb.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Contacting Facebook...');
setTimeout(function() {
startOAuth();
}, 500);
});
console.log('set twitter click handlers');
var tw = document.getElementById('twitterOn');
tw.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Fetching access token...');
setTimeout(function() {
twittergetAccessToken();
}, 500);
});
}
I would start by adding some debug code in your click handler to see if that's getting called when you click the button in the first place.
If it is, then I recommended you use Web Inspector (console) to see if there are any errors. If there are, they'll show up there.
Good reference for Web Inspector here - http://developer.blackberry.com/html5/documentation/web_inspector_overview_1553586_11.html
If the click handler is not being fired then perhaps you have the wrong element ID, or the setClickHandlers function is not being executed.
I've been trying to figure out how to create and display a form inside of a Dialog using Dojo 1.7.
I want my dialog to look something like this:
All the samples I have seen do it using Markup, but none using AMD
When you create a dialog, you can use a widget (e.g. a form) as content. So, for example, you could do:
require([
"dijit/Dialog",
"dijit/form/Form",
"dijit/form/TextBox",
"dijit/form/Button",
"dojo/domReady!"
], function(Dialog, Form, TextBox, Button)
{
var form = new Form();
new TextBox({
placeHolder: "Name"
}).placeAt(form.containerNode);
new Button({
label: "OK"
}).placeAt(form.containerNode);
var dia = new Dialog({
content: form,
title: "Dialog with form",
style: "width: 300px; height: 300px;"
});
form.startup();
dia.show();
});//~require
require() is provided by Dojo. It loads the dependencies (Form, Dialog etc) and then runs the given function which creates the widgets. However, because we include domReady! among the dependencies, Dojo makes sure the DOM is fully loaded and ready first.
Because I have dia.show() in that function too, the dialog will actually be shown as soon as the page is opened. Let's say you wanted to show the dialog when some button on your page is clicked instead:
require([
"dijit/Dialog",
"dijit/form/Form",
"dijit/form/TextBox",
"dijit/form/Button",
"dojo/on", // Added this!
"dojo/domReady!"
], function(Dialog, Form, TextBox, Button, onEvent)
{
// ... as above, we create the dialog and form when the page loads
// but it remains hidden until we call dia.show() ...
form.startup();
// dia.show(); Commented out this!
onEvent(document.getElementById("someButtonOnYourPage"), "click",
function()
{
dia.show();
});
});//~require
I am relatively new to web development, so perhaps this is a rookie question. I am trying to set up an ASP.NET MVC web site to implement DotNetOpenAuth as an OpenID relying party.
Right now it is all functioning, so that is pretty exciting. My goal though was to have the OpenID authentication take place it a popup window. This seems to be the default behavior when you using WebForms with the DNOA custom controls, but I haven't been able to figure it out in MVC.
I thought I was getting close with this:
var request = OpenIdRp.CreateRequest(id);
request.AddExtension(new UIRequest(Mode = UIModes.Popup));
But the Mode field of the UIRequest is read-only.
Does anybody know how to create a request that tells the OpenID provider to open a popup window?
Thanks for any help. So far I have been unable to track down any samples of this in action.
On the v.3.4.5 I am using, Mode property of the UIRequest has both getter and setter.
var req = openid.CreateRequest(openid_identifier);
// Add UI Request
if (req.DiscoveryResult.IsExtensionSupported<UIRequest>())
{
req.AddExtension(new UIRequest()
{
Mode = UIModes.Popup
});
You have to create the popup yourself. After the authentication takes place, you should refresh the parent window and close the popup.
At the form's submission I have
<form action="/Account/OpenIdLogOn" target="popupWin" onsubmit="return openWindow('/Account/OpenIdLogOn', 'popupWin', 500, 500);">
where
function openWindow(url, wname, width, height) {
window.open(url, wname, "height=" + height + ",width=" + width + "location = 0, status = 1, resizable = 0, scrollbars=1, toolbar = 0");
return true;
}
and at the result view I have the following javascript
<script type="text/javascript">
$(function () {
if (window.opener) {
window.opener.location.href = window.opener.location.href;
window.close();
}
});
</script>
I hope this makes sense.
The Nerddinner site has exactly what you need. It's written in MVC, and you can download the source code here: http://nerddinner.codeplex.com/ .