new to this... how to call a method in a method (solved)
hi
i have problem understanding how i can call moveItems.
i traid this:
this.moveItems;
$(this).moveItems;
methods.moveItems;
methods.moveItems;
videoribbon.moveItems;
this works.. but that's a bad one i think
$(this).videoribbon('moveItems');
- (function( $ ) {
- var methods = {
- init : function(options) {
- $('#ribbon ul li').find('video').on('ended', function(event)
- {
- //$("#ribbon ul").moveItems();
- //methods.moveItems;
- //videoribbon.moveItems;
- //$(this).videoribbon('moveItems');
- $('#ribbon ul li').find('video').get(1).play();
- });
- },
- moveItems : function( ) {
- alert('test');
-
- },
- };
- $.fn.videoribbon = function(methodOrOptions) {
- if ( methods[methodOrOptions] ) {
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
- // Default to "init"
- return methods.init.apply( this, arguments );
- } else {
- $.error( 'Method ' + method + ' does not exist on jQuery.videoribbon' );
- }
- };
- })( jQuery );
solution:
- (function( $ ) {
- var methods = {
- init : function(options) {
- $objectc = $(this);
- $('#ribbon ul li').find('video').on('ended', function(event)
- {
- //$("#ribbon ul").moveItems();
- //methods.moveItems;
- //videoribbon.moveItems;
- //$(this).videoribbon('moveItems');
methods.moveItems($objectc);
- $('#ribbon ul li').find('video').get(1).play();
- });
- },
- moveItems : function($objectp) {
- $objectp.dosometthing
- alert('test');
-
- },
- };
- $.fn.videoribbon = function(methodOrOptions) {
- if ( methods[methodOrOptions] ) {
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
- // Default to "init"
- return methods.init.apply( this, arguments );
- }
- };
- })( jQuery );
a other solution
- (function( $ ) {
- var methods = {
- init : function(options) {
- $objectc = $(this);
- $('#ribbon ul li').find('video').on('ended', function(event)
- {
- //$("#ribbon ul").moveItems();
- //methods.moveItems;
- //videoribbon.moveItems;
- //$(this).videoribbon('moveItems');
$.fn.videoribbon.moveItems();
- $('#ribbon ul li').find('video').get(1).play();
- });
- },
-
- };
$.fn.videoribbon.moveItems = function(){
return $objectc.dosomething
}
- $.fn.videoribbon = function(methodOrOptions) {
- if ( methods[methodOrOptions] ) {
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
- // Default to "init"
- return methods.init.apply( this, arguments );
- }
- };
- })( jQuery );