Skip to content

Instantly share code, notes, and snippets.

@Smenus
Created February 16, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Smenus/d7ff6b608a0d262aadad to your computer and use it in GitHub Desktop.
Save Smenus/d7ff6b608a0d262aadad to your computer and use it in GitHub Desktop.
class ComboView extends Marionette.ItemView<ComboField>
{
/**
* Constructor logic for ComboView.
* @param {ComboField} model The model for the ItemView.
*/
constructor(model: ComboField)
{
this.ui = {
control: ".control-field input"
};
this.listenTo(model, "change:value", () => this.updateDisplay());
super({model: model});
}
/**
* Update the display to reflect the backing value.
*/
protected updateDisplay(): void
{
// Get the kendo object
let combobox = (this.ui.control as JQuery).data("kendoComboBox"); // Returns undefined
let test = (this.ui.control as JQuery).data("test"); // Also undefined
combobox.select(this.model.value.index);
}
/**
* Triggered after the view has been rendered
* Should do any post-rendering manipulation of el here
*/
public onRender(): void
{
// Make the field a kendo component
(this.ui.control as JQuery).kendoComboBox();
// Try adding another data value
(this.ui.control as JQuery).data("test", "test");
this.updateDisplay();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment