How is the text? plugin use baseUrl?

I am having trouble getting text! plugin to work on my requirejs website. It always includes lib / in the request url, however all other files (without using text!) Were successfully found and uploaded. Here is my directory structure:

WebContent/
  |--backbone/
        |--Bunch of folders and files
  |--config/
        |--config.js
  |--lib/
        |--jquery.js
        |--text.js
        |--require.js
  |--index.html

my index.html file:

<body>
    <div id="siteLayoutContainer"></div>
    <script data-main='config/config' src="lib/require.js"></script>
</body>

Configuration file:

requirejs.config({
    baseUrl: './',
    paths: {
        jquery: 'lib/jquery.js',
        backbone: 'lib/backbone.js',
        text: 'lib/text',
        application: 'backbone/application'
    },
    text: {
        env: 'xhr'
    }
});
require(['application'], function(App) {
    App.start();
});

I use text! the plugin looks like this:

define([
    'jquery',
    'text!backbone/templates/SomeTemplate.html'
], function(jQuery, NotFoundHtml) {
    //Some code here
}

So, in the above script, the template uses the URL: http: //localhost/lib/backbone/templates/SomeTemplate.html

and I expect it to be: http: //localhost/backbone/templates/SomeTemplate.html

I tried the following:

  • text.js require.js WebContent . ! , lib/ , html . .
  • baseUrl - .
  • config.js index.html script, require.js script - .
  • , , "!../backbone/templates/SomeTemplate.html -

, , . , , , ! baseUrl URL-, .

+4
1

. , , :

backbone: 'lib/backbone.js',

, text. , , ! , , . , , , paths, , , , . - paths:

"backbone/templates": "backbone/templates"

, , backbone/templates, backbone.

. , , jQuery Backbone.

+3

All Articles