开发者

OpenSocial create activity from submit click

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); });
  }
};
  1. 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); });
  }
};
  1. 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 '});
  2. Is at "simple as that i.e. use the createActivity function and it will use the OS framework to "post" to the activity.xml


Umm actually it is that "easy" pretty obvious really use getElementbyID and yes it adds another activity

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜