File1.js contains the definition of a JavaScript object, or rather, the creation of a literal object.
Within each pair of propertyName: value , an initialization of a new property is declared, so that the code is run only once when the object is created. For example, fbPicturesVM: new FbPicturesVM()
The properties of JavaScript objects can be functions, such as: initialize: function () {...}, In this case, whenever you run FbPicturesObj .initialize , this function will be launched.
Calls to ko.applyBindings are correct. This method expects the viewmodel and optional DOM element to become the second parameter. The jQuery expression (not exactly) is an array of the selected DOM elements, so this $("#fb-album-photos")[0] extracts the first DOM element from the jQuery expression if ko.applyBindings is required.
NOTE. As you suspect, the way to determine the model is not the best, to say the least. You can use the drop-down module template, which simplifies the work.
Module template output
In a few words:
var vm = (function() {
SPECIFY Expression with Instant Calling Function (IIFE) pattern .
var value = (function() {})();
This template defines an anonymous function that returns something. () at the end starts it, so the value is returned and stored in value ;
I recommend this patter because it is extremely easy to use and little error prone. Classic prototype inheritance, constructor, etc. Much harder to work.
You can easily convert this to a factory view model (something similar to a constructor, but not like a js constructor) by removing the - () call at the end - and saving the funcion definition so you can call it again.
var factory = function() {}; var vm1 = factory(); var vm2 = factory();