2015-08-19 2 views
0

Я пытаюсь создать простой виджет Backbase, однако, показывает мне ошибку ReferenceError: requireWidget не определен. Я думаю, что это связано с RequireJS, но сам его крючок ничего не делает. Может, кто-то знает, как с этим бороться?ReferenceError: requireWidget не определен

index.html файл:

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:g="http://www.backbase.com/2008/gadget" xml:lang="en"> 
<head> 
    <title>Todo Widget</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

    <g:preferences> 
     <g:preference name="limit" label="Todo's Limit" type="text" default="5" viewHint="none" /> 
    </g:preferences> 

</head> 
<body g:onload="requireWidget(__WIDGET__, 'todo')" class="todo-widget"> 
    <h1>Todo Widget</h1> 
</body> 
</html> 

И JS файл

define(["jquery"], function($) { 
    "use strict"; 

    var self; 

    function Todo(widget) { 
     self = this; 

     self.widget = widget; 
     self.$widget = $(widget.body); 

     return self; 
    } 

    Todo.prototype.init = function() { 
     window.alert('it works!'); 
    } 

    return function(widget) { 
     var todo = new Todo(widget); 
     todo.init(); 
    } 
}); 

ответ

0
Basically you need to reference the the require conf file in your HTML FILE from the launchpad. 
**<script src="../../../launchpad/conf/require-conf.js"></script>** 
the path ../ depends on the your path of the source folder. 

You can also write the Widget without the require js as below with your own function 

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:g="http://www.backbase.com/2008/gadget" xml:lang="en"> 
    <head> 
     <meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" /> 
     <title>Hello World</title> 
     <g:preferences> 
      <g:preference name="FontSize" type="range" min="8" max="24" step="2" 
      default="12" label="Font size" onchange="applyFontSize(__WIDGET__)" 
      viewHint="user" /> 
     </g:preferences> 
     <script type="text/javascript"> 
      function applyFontSize(oWidget) { 
       oWidget.body.style.fontSize=encodeURIComponent(oWidget.getPreference('FontSize'))+'px'; 
      } 
     </script> 
    </head> 
    <body g:onload="applyFontSize(__WIDGET__)"> 
     <p>Hello World</p> 
    </body> 
</html> 

Also you can register on the http://my.backbase.com.. to have access to more documentation 
Смежные вопросы