Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import Backbone from 'backbone';
  2. import $ from 'jquery';
  3.  
  4. import AppFinder from './app_finder_test';
  5.  
  6. export default Backbone.Router.extend({
  7. routes: {
  8. '': 'home',
  9. 'main_app_part': 'mainAppPart',
  10. '*handleMissingRoute': 'handle404'
  11. },
  12.  
  13. home() {
  14. $('#app').html("You're on the home page");
  15. },
  16.  
  17. mainAppPart() {
  18. $('#app').html("You're viewing part of the main app, no async bundle loading here");
  19. },
  20.  
  21. handle404(path) {
  22. const mini_app_name = AppFinder(path);
  23.  
  24. if (mini_app_name) {
  25. + const handler = require('bundle!./apps/' + mini_app_name + '/index.js');
  26. - require.ensure([], require => {
  27. + handler(bundle => {
  28. - const App = require('./apps/' + mini_app_name + '/index.js').default;
  29. + const App = bundle.default;
  30. App();
  31. Backbone.history.loadUrl();
  32. });
  33. } else {
  34. alert('404');
  35. }
  36. },
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement