[twitter-dev-anywhere] How to make the tweet button active by default in TweetBox

9 views
Skip to first unread message

Maxim Grinev

unread,
Apr 21, 2010, 11:58:18 AM4/21/10
to Twitter Anywhere Development
Hello all,

I have added TweetBox as shown below. Everything works fine except
the tweet button is not active when the page is loaded. I have to
click on the input box to make it active. As I have a predifined text
I want it to be active by default. How can I make the tweet button
active by default?

<div id="tweetbox"> </div>

<script type="text/javascript">
var idvar = "tweetbox";

twttr.anywhere(function (T) {

T("#tweetbox").tweetBox({
label: "Tweet me:",
height: 100,
width: 210,
defaultContent: "@maxgrinev Hello!",
onTweet: function (tweet, htmlTweet) {
document.getElementById(idvar).setAttribute("style",
"display: none;");

}
});

});

</script>

Salute,
Maxim Grinev


--
You received this message because you are subscribed to the Google Groups "Twitter Anywhere Development" group.
To post to this group, send email to twitter-de...@googlegroups.com.
To unsubscribe from this group, send email to twitter-dev-anyw...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/twitter-dev-anywhere?hl=en.

kovshenin

unread,
Apr 21, 2010, 12:15:16 PM4/21/10
to Twitter Anywhere Development
Same issue, that's why I'm still looking for the onComplete event for
tweetBox(). One work around is to use javascript timers and fire
a .focus() in the textarea, like this:

setTimeout(function() {
$(".twitter-anywhere-tweet-box").focus();
$(".twitter-anywhere-tweet-box").contents().find("#tweet-
box").focus();
}, 1000);

Maxim Grinev

unread,
Apr 22, 2010, 5:20:29 AM4/22/10
to Twitter Anywhere Development
Thank you, Kovshenin. It works.

Twitter Anywhere developers, I also vote +1 for the onComplete event
for tweetBox(). Or the button should be active by default in case of
predifined label. It is unusable without it in case of predefined
label: users just don't understand why the button is not active if the
text is already in the box.

Taylor Singletary

unread,
Apr 22, 2010, 9:52:37 AM4/22/10
to twitter-de...@googlegroups.com
Hi Folks,

We do have some means you can accomplish this today, but I want to warn you that we're still improving @Anywhere regularly, and more convenient approaches for this are going to arrive. If you choose the approach I outline below, I recommend that you make your code resistant to the possibility that the "complete" callback may change in name and scope. We'll keep the group updates when the revised methods for this arrive.

Here's an example of accomplishing this using jQuery:
// Using jQuery
twitter("#placeholder-1").tweetBox({

 complete: function (tb) {
   $(".twitter-anywhere-tweet-box")[0].contentWindow.document.getElementById("tweet-box").focus();
 }

});


And if you happened to be using YUI:
twitter("#placeholder-1").tweetBox({

 complete: function (tb) {
   var iframe = Y.Node.getDOMNode(Y.one(".twitter-anywhere-tweet-box"));
   iframe.contentWindow.document.getElementById("tweet-box").focus();
 }

});

Hope this helps!

Taylor Singletary
Developer Advocate, Twitter
http://twitter.com/episod

webm...@joegibbsracing.com

unread,
Apr 22, 2010, 8:10:05 PM4/22/10
to Twitter Anywhere Development
Total newbie here. Can someone tell me exactly where to paste the
code in either of these two solutions?

Very much appreciated - thanks,

Bryan

On Apr 22, 9:52 am, Taylor Singletary <taylorsinglet...@twitter.com>
wrote:
> Hi Folks,
>
> We do have some means you can accomplish this today, but I want to warn you
> that we're still improving @Anywhere regularly, and more convenient
> approaches for this are going to arrive. If you choose the approach I
> outline below, I recommend that you make your code resistant to the
> possibility that the "complete" callback may change in name and scope. We'll
> keep the group updates when the revised methods for this arrive.
>
> Here's an example of accomplishing this using jQuery:
>
> // Using jQuery
> twitter("#placeholder-1").tweetBox({
>
>  complete: function (tb) {
>
> $(".twitter-anywhere-tweet-box")[0].contentWindow.document.getElementById("tweet-box").focus();
>  }
>
> });
>
> And if you happened to be using YUI:
>
> twitter("#placeholder-1").tweetBox({
>
>  complete: function (tb) {
>    var iframe = Y.Node.getDOMNode(Y.one(".twitter-anywhere-tweet-box"));
>    iframe.contentWindow.document.getElementById("tweet-box").focus();
>  }
>
> });
>
> Hope this helps!
>
> Taylor Singletary
> Developer Advocate, Twitterhttp://twitter.com/episod
> > twitter-dev-anyw...@googlegroups.com<twitter-dev-anywhere%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/twitter-dev-anywhere?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Twitter Anywhere Development" group.
> > > To post to this group, send email to
> > twitter-de...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > twitter-dev-anyw...@googlegroups.com<twitter-dev-anywhere%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/twitter-dev-anywhere?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Twitter Anywhere Development" group.
> > To post to this group, send email to twitter-de...@googlegroups.com
> > .
> > To unsubscribe from this group, send email to
> > twitter-dev-anyw...@googlegroups.com<twitter-dev-anywhere%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages