OpenSocial create activity from submit click
Posted
by russp
on Stack Overflow
See other posts from Stack Overflow
or by russp
Published on 2010-06-07T12:41:37Z
Indexed on
2010/06/08
7:02 UTC
Read the original article
Hit count: 250
Hi I'm "playing with OpsnSocial" and think I get a lot of it (well thanks to Googles' bits) but one question if I may. Creating an activity
Lets say I have a form like this (simple)
<form>
<input type="text" name="" id="testinput" value=""/>
<input type="submit" name="" id="" value=""/>
</form>
And I want to post the value of the text field (and or a message i.e "just posted" to the "users" activity.
Do I use a function like this?
function createActivity() {
if (viewer) {
var activity = opensocial.newActivity({
title: viewer.getDisplayName()
+ ' VALUE FROM FORM '});
opensocial.requestCreateActivity(activity, "HIGH",
function() { setTimeout(initAllData,1000); });
}
};
If so, how do I pass the text field value to it - is it something like this?
var testinput = document.getElementById("testinput");
so the function may look like
function createActivity() {
if (viewer) {
var activity = opensocial.newActivity({
title: viewer.getDisplayName()
+ testinput });
opensocial.requestCreateActivity(activity, "HIGH",
function() { setTimeout(initAllData,1000); });
}
};
- And how do I trigger the function by using the submit button. In my basic JQuery I would use
$('#submitID').submit(function(){ 'bits in here '});
- Is at "simple as that i.e. use the createActivity function and it will use the OS framework to "post" to the activity.xml
© Stack Overflow or respective owner