7

I want to create a control using the jquery ui framework. I know that I have to use as base the jquery.ui.widget.js as a factory.

This control I want to create has a behavior similar to the tabcontrol. I want to create a tileview, so when yo select a content in a panel of multiples views... it expands and the others collapse to a side of the control. Like this one http://demos.telerik.com/silverlight/#TileView/FirstLook Is there any tutorial, step by step to create a custom widget?

2

1 Answer 1

7

A good starting point is jQuery UI documentation on this topic: http://wiki.jqueryui.com/w/page/12138135/Widget-factory

At minimum your widget must implement following code (sample taken from documentation):

(function( $ ) {
  $.widget( "demo.multi", {

    // These options will be used as defaults
    options: { 
      clear: null
    },

    // Set up the widget
    _create: function() {
    },

    // Use the _setOption method to respond to changes to options
    _setOption: function( key, value ) {
      switch( key ) {
        case "clear":
          // handle changes to clear option
          break;
      }

      // In jQuery UI 1.8, you have to manually invoke the _setOption method from the base widget
      $.Widget.prototype._setOption.apply( this, arguments );
      // In jQuery UI 1.9 and above, you use the _super method instead
      this._super( "_setOption", key, value );
    },

    // Use the destroy method to clean up any modifications your widget has made to the DOM
    destroy: function() {
      // In jQuery UI 1.8, you must invoke the destroy method from the base widget
      $.Widget.prototype.destroy.call( this );
      // In jQuery UI 1.9 and above, you would define _destroy instead of destroy and not call the base method
    }
  });
}( jQuery ) );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.