Qualtrics: Automatic blinking cursor (focus) does not work on JFE, only on SE surveybuilder

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:27:39

问题


This has been an ongoing issue for me with my Qualtrics survey, where I need an automatic blinking cursor to appear in a textbox as soon as the page/question appears. It works flawlessly using Qualtrics' SE survey builder, but it does not work properly on JFE. Qualtrics could not help me with the issue, and would revert my surveys back to SE, but now they will no longer revert it back to SE so I need to solve this issue.

My code is as follows

$("QR~2_QID1").select();

This also works on SE

document.getElementById("QR~QID1").select();

And this:

var input = document.getElementById('myTextInput');

input.select();

When I use the same code with a JFE survey, it appears to work in the preview, where a blinking cursor appears on the mobile side, but I am still able to type and have the text appear on the desktop side. However, when using the actual survey link, no cursor appears, and I am not able to type unless I click the textbox (which I want to avoid).

I believe the issue has something to do with mobile compatibility. The SE survey preview does not include a mobile version, and it might be that the code on the JFE version is defaulting to mobile for some reason (we are excluding mobile users for our research). I wonder if there is a way to turn off mobile compatibility in JFE.

Something else that I noticed, is that when I create a new survey, and include a textbox with the code on the first page, it actually works properly. However, if I put a multiple choice question on the first page with a page break, the textbox no longer has a blinking cursor on the second page.


回答1:


This works fine for me in jfe to focus on the first text input in a question:

Qualtrics.SurveyEngine.addOnload(function() {
    $(this.questionId).down('.InputText').focus();
});

EDIT: Deferring execution might help with conflicts either with page transition or other scripts:

Qualtrics.SurveyEngine.addOnload(function() {
    $(this.questionId).down('.InputText').focus().defer();
});


来源:https://stackoverflow.com/questions/44889061/qualtrics-automatic-blinking-cursor-focus-does-not-work-on-jfe-only-on-se-su

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!