more G-Labs products

Author Topic: Widget buttons  (Read 1203 times)

May 01, 2014, 10:20:04 PM
Read 1203 times

maxflax

  • ***
  • Information
  • Full Member
  • Posts: 90
Building a widget to my program and wanted buttons in the controlwidget but seems that Im failing at the for some reason, only getting
the text of the button adding it to my html widget.

What am I doing wrong? I want a controlgroup containing 3 buttons in the widget and not in a popup.

May 01, 2014, 11:41:23 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Since widgets are dynamically added, if you want jquery mobile styles to be applied, you have to call trigger('create') for the widget container.
This can be placed inside the RenderView function after the var container = $(cuid);:

Code: [Select]
container.trigger('create');

It is recommended to call this only once, so add a "Initialized : false" field next to the GroupName, Description, etc..., fields.
So the code should look like this:

Code: [Select]
[{
    Name: "My Widget",
    Author: "Foo Bar",
    Version: "2014-05-01",
    GroupName : '',
    IconImage : 'pages/control/widgets/homegenie/generic/images/mydefaultimg.png',
    Description : '',
    Initialized : false,

    RenderView: function (cuid, module) {
        var _this = this;
        var container = $(cuid);
        var widget = container.find('[data-ui-field=widget]');
        var controlpopup = widget.data('ControlPopUp');
        // apply jquery mobile styles
        if (!this.Initialized)
        {
            container.trigger('create');
            this.Initialized = true;
        }
        // ...       
    }

 }]

Cheers,
g.