2015-08-19 2 views
0

J'essaie de créer un widget simple Backbase, cependant, me montre une erreur ReferenceError: requireWidget n'est pas défini. Je pense qu'il est associé à RequireJS mais son crochet lui-même ne fait rien. Peut-être que quelqu'un sait comment y faire face?ReferenceError: requireWidget n'est pas défini

fichier 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> 

Et 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(); 
    } 
}); 

Répondre

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