1

FBJS is driving my mental, I am having problems with selecting elements. I have the following on the content of my page:

 <button id="sendmessage" type="submit" style="border: 0; background: transparent">
        <img src="Button.png" alt="Submit" />
        <div id="output">Send Message</div><span id="overlay"></span>
  </button>

And as part of my FBJS I have

var refSendMessage = document.getElementById('sendmessage');
var refOutput = document.getElementById('output');

However

refSendMessage.setDisabled(true);

Gets the error Uncaught TypeError: Cannot call method 'setDisabled' of null

But

refOutput.setTextValue("Sending...");

Works fine!

Why is the type of refSendMessage null but refOutput is fine? The ID's are declared in the same place?

Need a JS wizard please :-)

Many thanks for your time,


Extra information, if I use <span id="sendmessage"></span>, no error occurs. Could this be a Facebook Bug?

1
  • It very well could be that Facebook isn't handling the button element properly and takes a crap. Commented Mar 11, 2011 at 1:29

1 Answer 1

3
  1. Make sure you don't have anything else with id 'sendmessage' on the page.
  2. Try to change <button> to an <input type="button"> with id 'sendmessage' and see if document.getElementById('sendmessage') still returns null. If not, perhaps Facebook has trouble with the <button> element?
  3. Try looking at the rendered markup and make sure the Facebook-generated id specified inside document.getElementById() matches the Facebook-generated id of your button element. If they don't match, then of course a null will be returned.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.