Approved graph action does not work - facebook-graph-api

I've struggled with this for hours... new to creating graph actions... why doesn't our approved graph action work? We expect that when a user clicks the "Click Here!" button that it will show that they've scheduled a blood donation on their timeline. We have a form button coded precisely as outlined in the FB tutorial, and it's on a page tab we've added to a page, but nothing happens when you click the "Click Here!" button.
The page tab in question -> http://www.facebook.com/cityofhope.donateblood/app_323470837712150
Here's the code:
<script type="text/javascript">
function postSchedule()
{
FB.api(
'/me/cohblooddonor:schedule',
'post',
{ blood_donation: 'http://www.cityofhope.org/giving/Documents/blood-donor.html' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('You've shared with your friends! Action ID: ' + response.id);
}
});
}
</script>
And the button:
<form>
<input type="button" value="Click here!" onclick="postSchedule()" />
</form>
Any help is appreciated! I've been going at this for hours. Is it an authentication issue? thanks in advance!

You've got a syntax error due to mismatched quotes on line 58 of your source: 'You've ...'
You could escape the literal apostrophe with a backslash, or change "You've" to "You have".
You also have a few other errors on the page. Check these out using the Javascript console on a modern browser.

Related

How to avoid form submission in Django on pressing enter key?

I wish to prevent form submission on pressing enter in django. I have searched over internet, and found jquery/javascript based solution. I have tried to use the below js snippet but it is not working. Can anyone help me out here? I am using Django==2.2 version.
<script>
document.getElementById('name').addEventListener('keypress', function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
</script>

Foundation Joyride : Invalid variation error

I created one button manually like below in foundation joy ride, in-order to disable the foundation joy ride completely.
neverShowJoyRide: function(){
$(document).foundation('joyride', 'hide'); //hide the joy ride on trigger
},
render: function () {
var self = this;
return (
<ol className="joyride-list" data-joyride>
<li data-id="startJoyRide" data-text="Next" data-options="prev_button: false; tip_location: left">
<p>Welcome to XXXX - Would you like to take a guided tour of the site ?</p>
<button className="small button" onClick={this.neverShowJoyRide}>Never show this Again</button>
</li>
</ol>
);
}
I am using this code in react. When i render this code in my react component, it is not showing any error. But when i click on the button "never show this again" then i am getting an error message like:
invariant.js:42 Uncaught Error: Invariant Violation: ReactMount: Two valid but unequal nodes with the same data-reactid: .0.0.5.0.2.0.0.1
Does any one have any idea about this? please help me. Thanks in advance.

SharePoint 2013 - How do I add a button to a page that opens a list form when pressed?

I am currently working within SharePoint 2013 and was wondering if there was a way to create a button on a home page that when pressed, opens a list form in a modal window? (or in a non modal window).
I understand the method of using "Embed code" to code a button; however, it doesn't seem to allow me to link it to a list form, or edit what the button actually does.
Example:
1. An employee lands on the home page and wants to initiate a Purchase Request through the company.
2. The employee clicks on a button labeled "Click here to submit a Purchase Request".
3. After clicking, the Purchase Request form opens from the Purchase Request list (pre-created).
Thank you for your assistance!
You can use something like this in a CEWP to redirect to the new item form:
<button onclick="formRedirect(); return false;">New Form</button>
<script>
function formRedirect() {
window.location = "/test/Lists/LinkList/NewForm.aspx"
}
</script>
To display it in Modal form you will need to use the NewItem2 JS function:
<button onclick="NewItem2(event, "https://Your.SP.Site/_layouts/15/listform.aspx?PageType=8&ListId=%7B59E6FE0C%2D02C6%2D4B00%2D9B6A%2D87116A2DF594%7D&RootFolder="); return false;">New Form</button>
To get this to work you will need the list web part on the page where the button is located, though it can be hidden from view by setting th chrome to none and minimizing it. You can copy the function from the new item button in the list you wish to display, it is stored as an 'OnClick' property.
I know I am late to this but I just figured how to do this for the "Upload Document" for a document library. It took me a while but I stumbled upon it through trial and error using F12. I will provide both script for a "LIST and LIBRARY" form.
FOR A LIST:
<a href="#" onclick="openDialog('YourSiteURL/Lists/YourListName/NewForm.aspx');">
<img src="YourSiteImageURL" alt="NameofYourImage">
</a>
<script>
function openDialog(pageUrl) {
var options = {
url: pageUrl,
title: 'NameofYourForm', /* Enter the name you want for your form */
allowMaximize: false,
showClose: true,
width: 1225, /* Modify for your needs */
height: 800 /* Modify for your needs */
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
</script>
FOR A LIBRARY:
This is for use with a button:
<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&RootFolder=" target="_self" data-viewctr="702">
<img src="URLforYourButtonImage" alt="NameofYourButton">
</a>
This is for use with text:
<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&RootFolder=" target="_self" data-viewctr="702">Add document
</a>

Remember preferable language

I've made a simple website for my daughter.
It is in Dutch and for every page there is a English version as well.
Dutch URL: nl/index.html
English URL: eng/index.html
What I would like to do is give the visitor the option to set one language as preference. So if they come to this site the next time they will automatically linked to the preferable page.
I know this can be done with a cookie and saw the explanation on this forum ( How to remember the currently clicked url? javascript?PHP? ).
I've tried to make this work but apparently I am doing something wrong?
Can somebody guide me through step by step? That would be great!
Kind regards,
Jurgen
If you are familiar with jQuery you can use the cookies plug-in to persist the user's language choice and redirect him to the appropriate page every time he comes back to your site. Bellow is a sample code that uses two buttons to set the language:
First you declare the jQuery scripts (I use to store them in a Script folder, hence the following):
<script type="text/javascript" src="../Script/jquery-1.7.2.js"></script>
<script type="text/javascript" src="../Script/jquery.cookie.js"></script>
Then you define the page ready event like this:
$(function () {
var url = 'your_url';
var english_page = 'eng/index.html';
var dutch_page = 'nl/index.html';
if ($.cookie('default_page') != null) {
if (window.location.href != url + '/' + $.cookie('default_page')) {
window.location.href = url + '/' + $.cookie('default_page');
}
}
$('#set_english_butt').click(function () {
$.cookie('default_page', english_page, { expires: 999 });
alert('English was set as the default language');
});
$('#set_dutch_butt').click(function () {
$.cookie('default_page', dutch_page, { expires: 999 });
alert('Dutch was set as the default language');
});
});
Which is hooked to some html buttons in you page:
<div>
<span>Select your language:</span>
<button id="set_english_butt">English</button>
<button id="set_dutch_butt">Dutch</button>
</div>

Facebook Phonegap xCode: Program Freaks Out When Returns From Authorization

Here's what I want: Dialog box that says "Hey we gotta login to facebook and authorize" and then a button that goes to the facebook login page, then for it to return to a main page (the one that launched the dialog.
Right now, the dialog pops up fine, then it properly redirects to facebook, then redirects back but instead of just popping out to the main page, it pops out, then pops back up, then pops back out again. I'm sure I've done something I'm not supposed to. Also PLEASE comment on my jquery because I'm new to it and would rather not get into bad habits.
Here's what I have.
index.html which has this dialog box in the body:
<div id="dialog1" data-role="dialog" data-theme="b">
<div data-role="header" data-position="inline">
<h1> Welcome!</h1>
</div>
<div data-role="content">
<p>
<h5> Hey! Welcome to Tag Search. We need to take a few steps to set up the app. <br><br>
First you have to login to facebook and authorize Tag Search. Don't worry, we'll never post anything to your wall unless you tell us to! <br>
</h5>
</p>
<a id="loginBtn" data-role="button">Click Here to Login!</a>
</div>
</div>
In my <script> tags I have this event listener:
$("#loginBtn").bind("click",function(x){
$('#dialog1').dialog('close');
login();
});
Also:
function login() {
FB.login(
function(response) {
console.log(response.session);
if (response.session) {
getLoginStatus();
//alert('logged in');
} else {
alert('not logged in');
}
},
{ perms: "email, friends_photos, offline_access" }
);
}
And:
function getLoginStatus() {
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
//alert('Connected');
if(!session_access_token)
session_access_token=response.session.access_token;
getMe();
$("#loginout").text('Logout');
$("#loginout").bind('click', function(){logout()});
} else {
$.mobile.changePage('#dialog1', 'pop');
}
console.log(response);
});
}
getLoginStatus is called on document.addEventListener('deviceready', function() {
just guessing, but these should be good ways to start:
A) multiple binds (easier)
It could be you are binding to your button multiple times, so when you click on it, your functions fire multiple times.
To check just add a console.log to your click handler and see how often it fires when you click on the button.
You have to keep in mind how Jquery Mobile handles pages - the first page loaded is your "anchor-page" which should stay in the DOM as long as you are not rel="external"-linking to another page (which will then become your new anchor-page). All additional pages (including dialogs) are appended to the anchor-page DOM, when you load them. Your anchor page is just hidden, but is not gone, so it's easy to bind multiple times thinking "page is gone, need to bind again". Using Phonegap I think you have a single file with all pages contained, so this should also hold there.
B) Too many hashchanges firing (tricky)
Think of JQM transitions as two parallel processes, because a hashChange fires along with every transition. On forward transitions, the hashchange is blocked (check JQM $.mobile.urlHistory.ignoreNextHashChange), on backwards transitions it can pass and takes care of the reverse transition.
You would have to find out, which processes are triggered and blocked if your page is behaving strange. Console inside JQM in the _handleHashChange and click routing (search for "click routing " just before _handleHashChange) to see what happens.
My guess would be A)
Good luck and let me know if it works or if you have any more questons on both A) and B)