Call a function on another script after Twitter API call complete

javascript

#1

I am making a call to the Twitter API to get a list of tweets from a user and output them on a webpage. I am using iScroll.js to create a clean scrolling container for the tweets, but I need a way to call a function defined within a separate javascript file that initially created the scrolling area, after the Twitter API is finished with the call. This is the only way I can get the scrolling area to recalculate the actual height of the area. How could I make this happen?


#2

I’m not exactly sure what the question is. It sounds like more of a JavaScript question than a Twitter API question. But, if the question is, “Is it possible to call a JavaScript function from a separate source file?” then the answer is yes.


#3

Okay, great. How?


#4

If the JavaScript is in a webpage, use the <script> tag.
If the JavaScript is in a node application, use require.
If neither of these are familiar to you I suggest looking at some tutorials first to get a better understanding of the JavaScript programming environment.


#5

I am using require, but my function call to the other javascript file is still undefined and I am passing the script in the require array and adding the property to the require argument function call.


#6

It sounds like there might be something wrong with the way you are using require or with the way the function is exported in the file you are including with require. You are on the right track. You just need to debug this by a process of elimination.


#7

This would probably get better responses on stackoverflow tbh.