change event problem

8 posts, 0 answers
  1. Ismael
    Ismael avatar
    5 posts
    Member since:
    Apr 2014

    Posted 24 Apr 2014 Link to this post

    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.



  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 25 Apr 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Ismael
    Ismael avatar
    5 posts
    Member since:
    Apr 2014

    Posted 25 Apr 2014 Link to this post

    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

  5. Ismael
    Ismael avatar
    5 posts
    Member since:
    Apr 2014

    Posted 25 Apr 2014 in reply to Ismael Link to this post

    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
  6. Ismael
    Ismael avatar
    5 posts
    Member since:
    Apr 2014

    Posted 25 Apr 2014 in reply to Ismael Link to this post

    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
  7. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 28 Apr 2014 Link to this post

    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!
     
  8. Ismael
    Ismael avatar
    5 posts
    Member since:
    Apr 2014

    Posted 28 Apr 2014 in reply to Georgi Krustev Link to this post

    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.
  9. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 29 Apr 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready