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

[Solved] onchange event prevents click event on other elements

4 Answers 39 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brett
Top achievements
Rank 1
Brett asked on 29 Jul 2011, 12:30 AM
Using the code below, my save button click event does not fire if changes exist in the editor.  That is, it appears that the onchange event is canceling all other events?

@(Html.Telerik().Editor()
    .Name("NarrativeEditor")
    .ClientEvents(e =>
    {
        e.OnLoad("PPC_narrativeEditorOnLoad");
        // to do: if this change event exits, then save button click does not fire
        e.OnChange("PPC_narrativeEditorOnChange");
    })
    .Tools(t =>
        {
            t.Clear();
            t.Custom(settings => settings
                .Template(@<text>
                    <input type="submit" class="sunset editor-button save" title="Save" value="" onclick="alert('Save!!'); return false;" />
                </text>)
            );
            t.Custom(settings => settings
                .Template(@<text>
                    <input type="submit" class="sunset editor-button refresh" title="Refresh" value="" onclick="alert('Refresh!!'); return false;" />
                </text>)
            );
            t.Break();
            t.Bold();
            t.Italic();
            t.Underline();
            t.Strikethrough();
            t.Separator();
            t.FontName();
            t.FontSize();
            t.FontColor();
            t.BackColor();
            t.Separator();
            t.JustifyLeft();
            t.JustifyCenter();
            t.JustifyRight();
            t.JustifyFull();
            t.Separator();
            t.InsertUnorderedList();
            t.InsertOrderedList();
            t.Separator();
            t.Outdent();
            t.Indent();
            t.FormatBlock();
            t.Separator();
            t.CreateLink();
            t.Unlink();
            t.Separator();
            t.InsertImage();
        })
)

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Jul 2011, 10:06 AM
Hello Brett,

 I couldn't reproduce this problem. Find attached my test project. What is different in your case?

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Brett
Top achievements
Rank 1
answered on 29 Jul 2011, 12:08 PM
Hi Atanas,

Thanks for making a test project.  You've actually reproduced the problem perfectly.  Steps to reproduce:

1) Add some text to the editor
2) Click the "save" button
3) Note that the OnChange event fires and the "Change!" alert is displayed.
4) Note the *absence* of the "Save!" alert.  The input's onClick event does not appear to fire.
5) If you change text and click the Save input twice, then the onClick event *does* fire and the "Save!" alert is displayed.

Now, contrast the above behavior with the following

1) Do *not* add or change any text in the editor
2) Click the "save" button
3) Note that the onClick event fires for the Save input and the "Save!" alert is displayed.

Note: It is not necessary for the input to be embedded in the control.  The same behavior occurs with any element on the page.

Thanks again,

Brett
0
Accepted
Atanas Korchev
Telerik team
answered on 29 Jul 2011, 12:32 PM
Hi Brett,

 I see it now. However if I remove the alert() from the change event handler the alert("Save") is displayed as expected. Still the change event handler is executed. Do you need to show alert() in both cases?

All the best,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Brett
Top achievements
Rank 1
answered on 29 Jul 2011, 06:33 PM
Atanas,

Thanks, you're exactly right.  Removing the alert solves the problem.  I'll be more careful to debug using a console in the future.

Thanks,

Brett
Tags
Editor
Asked by
Brett
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Brett
Top achievements
Rank 1
Share this question
or