Home Search Member List Faq Register Login  
UltimateEditorMVC
Client focus event

Thread Starter: jemmitch   Started: 01-08-2013 10:30 AM   Replies: 5
 Karamasoft Support Forums » General Discussions » UltimateEditorMVC » Client focus event
 Printable Version    « Previous Thread   Next Thread »
  08 Jan 2013, 10:30 AM
jemmitch is not online. Last active: 1/10/2013 3:35:58 AM jemmitch

Top 10 Posts
Joined on 08-22-2012
Posts 9
 Client focus event

I am trying to add a focus and blur handler to an mvc ultimateeditor.

My code looks like this:

function ReasonForMove_OnLoad() {
UltimateEditors['ReasonForMove'].AddEventHandler('focus', myhandleFocus);
UltimateEditors['ReasonForMove'].AddEventHandler('blur', handleBlur);
alert('onload');
}

My handlers look like this....

function handleBlur() {
alert('blur');
$(this).closest('.field-wrapper').removeClass("focus");
}

function myhandleFocus() {
alert('focus');
$(this).closest('.field-wrapper').addClass("focus");
}

My issue is the focus event handler never gets called. The blur handler does.

Any ideas?

Thanks

John

  
  08 Jan 2013, 12:03 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Client focus event
We tested it in ClientSideAPI.cshtml in the sample web app that comes with the installation as follows and it worked properly:

function UltimateEditorMVC1_OnLoad() {
   UltimateEditors[
'UltimateEditorMVC1'].AddEventHandler('focus', function (evnt) { HandleUltimateEditorFocus(evnt); });
}

function
HandleUltimateEditorFocus(evnt) {
   alert(
"focus");
}

Note that if you didn't set SetFocus to False, the editor takes the focus when the page is loaded. You need to click outside the editor and click inside to the alert.


  
  09 Jan 2013, 2:10 AM
jemmitch is not online. Last active: 1/10/2013 3:35:58 AM jemmitch

Top 10 Posts
Joined on 08-22-2012
Posts 9
Re: Client focus event
I have replicated this code in the example provided and it does not work for me.
This is possibly a version issue.
How do I get a copy of the latest version? Just download the demo?

John

  
  09 Jan 2013, 3:12 AM
jemmitch is not online. Last active: 1/10/2013 3:35:58 AM jemmitch

Top 10 Posts
Joined on 08-22-2012
Posts 9
Re: Client focus event
I did a little more experimenting with this issue by downloading the latest demo version of ultimate editor mvc and trying your sample code their.

It did not work.

After a few experiments it turns out this is a browser issue. It works in IE6 (Dont ask) and Chrome. But not Firefox (17.0.1) my development browser.

It would be useful if this behaviour could be confirmed and fixed.

  
  09 Jan 2013, 11:39 AM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: Client focus event
Firefox seems to have issues with the focus event. You can use the following workaround for Firefox:

var i = 0;
function UltimateEditorMVC1_OnLoad() {
   //UltimateEditors['UltimateEditorMVC1'].AddEventHandler('focusout', function (evnt) { HandleUltimateEditorFocus(evnt); }, true);
   document.getElementById("UltimateEditorMVC1i").contentWindow.document.addEventListener("focus", function (evnt) { HandleUltimateEditorFocus(evnt); }, true);
}

function
HandleUltimateEditorFocus(evnt) {
   document.getElementById(
"test").innerHTML = (i++);
   //alert("focus");
}

<span id="test"></span>

Note that we directly create the event handler on the editor content iframe element, which has the id of UltimateEditorMVC1i. You can basically append "i" at the end of your editor id.

When you use alert to test, it displays the alert many times and then it stops. We set the innerHTML property of a SPAN element to test.

  
  10 Jan 2013, 3:35 AM
jemmitch is not online. Last active: 1/10/2013 3:35:58 AM jemmitch

Top 10 Posts
Joined on 08-22-2012
Posts 9
Re: Client focus event
Understood. Will try this next week and feedback.
  
 Page 1 of 1 (6 items)
Karamasoft Support Forums » General Discussions » UltimateEditorMVC » Client focus event

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.