Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2165
Event handlers and MVC helper.
posted

1) How to set an event handler using a helper? I have this in an MVC4 app:

@(Html.Infragistics().TextEditor().ID("Name")
.Width(500)
.Value(Model.Name)
.Render())

I have tried all these:

$("#Name").bind("igtexteditorvaluechanged", function () {
     alert("EVENT!");
});

$("#Name").on("igtexteditorvaluechanged", function () {
     alert("EVENT!");
});

// Using the helper and delegate works BUT it generates another issue: when typing in the editor every character is duplicated.

$(document).delegate("#Name", "igtexteditorvaluechanged", function (evt, ui) {
     alert("EVENT!");
});

But, if instead of Html.Infragistics().TextEditor() I use:

<div class="editor-field">
     <input id="Name" /><input name="Name" type="hidden" />
</div>

$("#Name").igTextEditor({
     width: 500,
     nullText: "Enter Text", value: "@Model.Name", inputName: "Name"
});

Then the event is fired using delegate function (I haven't tested bind and on functions using jQuery) and the duplicated characters issue disappears.

2) How to show the correct value for latin characters?

When using the last approach I have another issue: displaying things like "OTOÑO" looks like "OTO&#209;O"  I have tried this:

nullText: "Enter Text", value: "@Html.Encode(Model.Name)", inputName: "Name"

But the result is: "OTO&amp;#209;O"

3) Delegate or On function?

In this link http://ko.infragistics.com/help/jquery/using_events_in_netadvantage_for_jquery.html say "The delegate function is obsolete in jQuery version 1.7, making on the preferred approach for establishing event handlers" I am using jQuery 1.8.2 so I would like to use the delegate function if there is no way to use a helper to set an event handler, but, as I said before, on function doesn't work with jQuery.