Search code examples
javascriptjqueryknockout.jsjqte

jqte duplicate the editor when open jquery popup


I am trying to set textarea to be richtexteditor using jqte, the control works properly when I used it in popup dialog by setting it after open the popup like

function EditItemPopup(item) {
    // Set Controls
    //debugger;
    ClearTips("validateTips");
    ClearTips("DetailvalidateTips");
    $.ajax({ type: "GET", url: BaseUrl + 'Get/?id=' + item.id })
        .done(function (data) {
            displayViewModelObject.item(data);
            displayViewModelObject.dialogLoading(false);
            SetOutComes();
            SetTools();
            $("#ddlUnits").val(displayViewModelObject.item().activity.unitID);

            $("#ddlProjectTools").select2("val", displayViewModelObject.item().selectedActivityTools);
            $("#ddlOutComes").select2("val", displayViewModelObject.item().selectedActivityOutComes);

            $("#dialog").dialog(opt).dialog("open");
            $('#Activity_Header').jqte();
            $('#Activity_Footer').jqte();

            $("#dialog").dialog(opt).dialog('option', 'width', BigDialogWidth);
            $("#dialog").dialog(opt).dialog('option', 'height', BigDialogHeight);

            $("#dialog").dialog(opt).keypress(function (e) { EnterKeyPress(e); });

            Z_Index = 1;

            // Set Validation
            $.validator.unobtrusive.parse($("#frmManager"));
            $('#frmManager').validate().resetForm();
            $('.field-validation-error').empty();
            EditInit();
        }).fail(function () { ShowAlert(msgLoadError, -1); });
};

this function is called by knockout binding. and when I try to make the same thing but by js method called to open the poup in click event (without knockout binding), the jqte library creates an editor inside another in each calling open popup method which like the prev method.

Thanks


Solution

  • the issue was in binding the form of the popup, I bound the form in the popup with a property of observable variable, this property is read from a json object which come in an ajax response, this is the reason of the problem, because the binding should be by an observable variable (not property or child in an observable variable)