Unresolved variable error in javascript files

For Facebook social plugins I use following code inline my html page:

<script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>



I also have a js file that includes my own functions.
I have this code snippet:
$(document).ready(function() {
  FB.XFBML.parse();
}

Although "FB" variable is set within http://connect.facebook.net/en_US/all.js
IDE marks "FB.XFBML.parse();" line with
"unresolved variable or type FB"

Is it possible to suppress this line without suppressing all other error warnings.
Thank you
3 comments
Comment actions Permalink

Hi Ben,
I suggest you to create custom javascript library for facebook api as described here. Download all.js file you mentioned and add it to created library as release sources. At this point FB becomes resolved, but XFBML is still unresolved. You can download facebook api javascript stub file from google closure library project (here) and attach it to the library as debug sources. This also improves completion, for example after "FB."

0
Comment actions Permalink

Actually, only the last mentioned file is enough :)

0
Comment actions Permalink

qKonstantin Thank you very much. Your solution solved my problem.

0

Please sign in to leave a comment.