javascript validation inside of fb:serverfbml block
I am trying validate input from a multi-friend-selector that I have embedded like so:
<fb:serverFbml>
<script type="text/fbml">
<form action="http://example.com/testSubmit.php" method="POST" onsubmit="return validate(this);">
<fb:multi-friend-input name="hidden"/>
<input type="submit" value="Submit"/>
</form>
</script>
</fb:serverFbml>
As expected, when rendered inside the iframe, the onsubmit function is prepended with my appid. I am assuming that I will need to embed my javascript somewhere within 开发者_Go百科the iframe, so that my definition of the validate() function can be prepended with my appid as well.
However, I have not had any luck doing so. I have tried embedding it the js a number of ways with no luck.
Thanks!
As I understand you have FBML canvas application.
In this case you don't need fb:serverFbml
wrapper. If it still doesn't work try adding event listeners as described here:
document.getElementById('my_form').addEventListener('submit',validate);
Since I need this page to render inside of fb as well as outside of fb and I would like flexibility, I believe that the best option for me will be to just use the js graph api and the jquery autocomplete widget. Does not seem like a lot of extra work, and will provide a lot more control on my end.
精彩评论