This is a migrated thread and some comments may be shown as answers.
Templates do not render when using Requirejs optimizer r.js
3 Answers 30 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Negin
Top achievements
Rank 1
Negin asked on 21 Apr 2015, 02:38 PM

Hi,

We are trying to use a spa project template that Kendo put up on the Visual Studio Gallery https://visualstudiogallery.msdn.microsoft.com/924c3074-ceab-4be4-87e1-e9e4fd4b6d61 , The problem we are having is when building the requirejs app with the optimizer r.js, the app runs and no errors but the templates are not rendering, I can see that the templates have been included in the built file. The app and templates render no problem when not using the optimizer. 

I have attached a project with the problem,

 

Templates not rendering when using built file 

<script src="@Url.Content("~/Scripts/require.js")" data-main="@Url.Content("~/App/main-built")"></script>

 

Templates rendering with non built file

  <script src="@Url.Content("~/Scripts/require.js")" data-main="@Url.Content("~/App/main")"></script>

 

Can anyone shed some light on this please?

 

Thanks

N.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Apr 2015, 06:29 AM
Hi Negin,

Adding the following line seems to do the trick:

 <script src="@Url.Content("~/Scripts/require.js")" data-main="@Url.Content("~/App/main-built")"></script>
 <script>
       require("main");
 </script>


Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Negin
Top achievements
Rank 1
answered on 23 Apr 2015, 01:04 PM

Hi Atanas,

When I add the extra script tag as you suggested

 <script>
       require("main");
 </script>

 

I get the following error in the console.

 

Error: Module name "main" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
http://localhost:55661/Scripts/require.js
Line 166

Thanks

 N.

0
Negin
Top achievements
Rank 1
answered on 23 Apr 2015, 03:29 PM

Hey Atanas,

 

I researched that error and I changed the code to this

     <script>
        require(['main'], function (main) {
            //main is now loaded.
        });
    </script>

 

And everything now seems to work. :)

 

Thanks

 

N.

Tags
SPA
Asked by
Negin
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Negin
Top achievements
Rank 1
Share this question
or