I'm learning DurandalJs and am trying to load a remote view from a different domain, however, requireJs keeps appending '.js' to the url for my html view resulting in a 404 error. My goal is to setup a framework where I can reuse html snippets for different clients utilizing my app. Here's the call to requirejs in the index.html file of my client app:
< script src="http://myframework.com/lib/require/require.js"
data-main="http://myframework.com/lib/framework"></script>
Notice I'm loading require.js from a totally different domain than my client app. I'm setting the entry point to my app to framework.js which exists on myframework.com server. Here's farmework.js:
var framework = 'http://myframework.com/';
require.config({
baseUrl: 'app/',
//Framework paths
paths:
{
'framework': framework,
'appBase': framework + 'appBase',
'lib' : framework + 'lib',
'durandal': framework + 'lib/durandal',
'jquery': framework + 'lib/jquery/jquery-2.1.0.min',
'knockout': framework + 'lib/knockout/knockout-3.1.0'
...
},
urlArgs: 'v=5.1.0.5'
});
require(['main']);
After framework.js on my remote server runs, I've established a set of paths to resources in my framework. I also set baseUrl to 'app' which resides on my client implementation. So, the net result is I have a remote set of resources, and a local set of resources. Please see this link: SO source for how I accomplished this
Anyways, everything is working up to this point. I'm able to load my remote resources. I'm able to load 'main' on my client. The problem happens when attempting to load a remote viewmodel and associated view. I have a 'appBase' path where I want to have common viewModels and views to load across different implementations of my app. I've set my route up as follows:
define(['plugins/router'], function (router)
{
return {
router: router,
activate: function () {
return router.map([
{ route: ['', 'home'], moduleId: 'appBase/viewmodels/home',title: 'Welcome'},
]).mapUnknownRoutes('hello/index', 'not-found')
.activate();
}
};
});
Notice, I'm using 'appBase/viewmodels/home' for the moduleId. appBase is one of the paths established in my framework that points to a location on my remote server. requireJs is finding the path to the remote resource, but it's appending '.js' to the html file extension resulting in a 404 not found. requireJs is producing this:
http://myframework.com/appBase/views/home.html.js
Any ideas on how to make DurandalJs load a viewmodule and its view on a remote server? Why is .js getting appended to the Url for the html resource? Thanks for your help.