This is a migrated thread and some comments may be shown as answers.

change event problem

7 Answers 438 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ismael
Top achievements
Rank 1
Ismael asked on 25 Apr 2014, 12:01 AM
Hola, tengo un problema al enlazar el evento "change" de un combobox, la función del evento jamás se dispara.

El escenario es el siguiente:

El combobox se carga en una vista parcial con sus datos mediante razor

@Html.Kendo().ComboBox().Name("uiCombobox").Filter("contains").Placeholder("Seleccionar...").DataTextField("Nombre").DataValueField("Id").BindTo(Model.Lista).Suggest(true).HtmlAttributes(new {style="width:500px;"})

En la vista padre se realiza el binding del evento change de la siguiente manera:

var comboboxchange= function (e) {
        var id= this.value();
        alert("Id:" + id);
    }

$(document).ready(function () {
        $("#uiCombobox").kendoComboBox();
        var combobox = $("#uiEventos").data("kendoComboBox");
        combobox.bind("change", comboboxchange);
    });

Al escoger una opción en el combobox nunca se despliega la alerta, pueden ayudarme, gracias.



7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 25 Apr 2014, 10:07 AM
Hello Ismael,

The official language for communication with our clients/people is English. If you are not able to continue the discussion in English, you can use some online translator (i.e. Google Translate).

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ismael
Top achievements
Rank 1
answered on 25 Apr 2014, 03:57 PM
sorry, I sent you the post again.

Ok I have a problem with the combobox control, I try to bind the "change" event to a function in javascript, but the event never fires.

The combobox is loaded in a partial view and data is loaded through razor, here is the code:

@Html.Kendo().ComboBox().Name("uiCombobox").Filter("contains").Placeholder("Seleccionar...").DataTextField("Nombre").DataValueField("Id").BindTo(Model.Lista).Suggest(true).HtmlAttributes(new {style="width:500px;"})

The parent view loads the partial view that contains the combobox using this lines:

@Html.Action("_ComboPartialView", "ComboController")

The parent view also binds combobox "change" event using this lines:

var comboboxchange= function (e) {
        var id= this.value();
        alert("Id:" + id);
    }

$(document).ready(function () {
        $("#uiCombobox").kendoComboBox();
        var combobox = $("#uiEventos").data("kendoComboBox");
        combobox.bind("change", comboboxchange);
    });

When I try to select an option from combobox the "alert" never shown, can you help me please, thanks

0
Ismael
Top achievements
Rank 1
answered on 25 Apr 2014, 04:02 PM
Sorry I have an error in the code that I post for the event binding this is the code that I have:

ar comboboxchange= function (e) {
        var id= this.value();
        alert("Id:" + id);
    }

$(document).ready(function () {
        $("#uiCombobox").kendoComboBox();
        var combobox = $("#uiCombobox").data("kendoComboBox");
        combobox.bind("change", comboboxchange);
    });

Thanks
0
Ismael
Top achievements
Rank 1
answered on 25 Apr 2014, 05:15 PM
I have to use this provisional solution, it uses the "change" event from JQuery:

$("#uiCombobox").change(comboboxchange);

var comboboxchange= function () {
        var combobox = $("#uiCombobox").data("kendoComboBox");
        var id = combobox .select();
        alert("Id:" + id);
}

Ok this temporary solution works for me, but I like to know why the combobox "change" event binding does not work using Kendo's documentation way
0
Georgi Krustev
Telerik team
answered on 28 Apr 2014, 11:08 AM
Hello Ismael,

The Observable.bind method works as expected on my end. Here is a simple Kendo Scratchpad demo, which wires the change event with bind method. Could you please verify that there is no JavaScript errors when the page is loaded? You can also check whether the code for event wiring is called in the correct time. In order to continue our investigation I will need a runnable test project, which reproduced the problem. Thus I will be able to review it locally and advice you further.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ismael
Top achievements
Rank 1
answered on 28 Apr 2014, 06:00 PM
Thank you for your replay, I create a project, this project contains two scenarios, the first is a change bind with kendo and the second is a change bind with jquery, I try to post the project but it is too large, so I send to you the project via email, thanks.
0
Georgi Krustev
Telerik team
answered on 29 Apr 2014, 11:00 AM
Hello Ismael,

You can enable the Nuget package restore of your solution. Click right click upon Solution name and click the "Enable Nuget packages restore..." button. Thus you can delete the assemblies part of the test project and hence reduce the size of the archive. Another option is to upload the project on different place and share the link for download here.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ComboBox
Asked by
Ismael
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Ismael
Top achievements
Rank 1
Share this question
or