On Dec 1, 9:00 pm, "Dirceu Barquette" <[EMAIL PROTECTED]>
wrote:
> to call the widget:
> $('<div></div>').attr({id:'the_widget'}).mywidget(fff:function(){});

I must be missing something :((. I have tried to reduce my code to the
next simple example.
Notice I want to override the method A.fff in B.init to something
different than the normal
behavior. I would expect the alert box to appear with a nice OK
inside, but it does not :((

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head></head>
<body>
<div id="ttt">whatever</div>
<script type="text/javascript" language="JavaScript"
src="jquery-1.2.6.js"></script>
<script type="text/javascript" language="JavaScript" src="ui/
jquery.ui.all.js"></script>
<script type="text/javascript" language="JavaScript">
(function($)
{
 $.widget( "ui.A", $.extend({}, $.ui.mouse,
 {
   try1: function ( )   { this.fff( -3 ) ; },
   try2: function ( i ) { this.fff( i ) ; },
   fff:  function ( i ) { alert( 'wrong ' + i ) ; }
} ) ) ;
})(jQuery);

(function($)
{
 $.widget( "ui.B",
 {
   init: function ( )
   {
     var cb = $(document.createElement( "div"    )) ;
     cb.A( { fff : function( i ) { alert( 'ok' ) ; } } ) ;

     this.prb  = function( ) { cb.A( "try2", 2 ) ; }
     this.getA = function( ) { return cb ; }

    $(this.element).append( cb ) ;
   }
} ) ;

$.extend($.ui.B, {
  getter: "getA"
} ) ;

})(jQuery);

var d = $("div#ttt") ;

d.B( ) ;
d.B( "prb", 2 ) ;
$(d.B( "getA" )).A( "try1" ) ;

</script>
</body>
</html>

Thanks,
David

Reply via email to