Render condition based on a snippet that checks if focus is on a specific field

  • 1
  • Question
  • Updated 2 years ago
Hey gang,

I'm noticing a reluctance to post because I feel like it's a simple question and that asking this question will out me as a novice. So, that's where I'm coming from with this question.


So here's my question:

When you are focused on a large text area, I want a responsive grid to render. How can I get a snippet to evaluate to true when the focus is on that field?

Here's my snippet attempt:

var params = arguments[0],	$ = skuid.$;
var sFocus;
if ($("#subjectiveField").is(":focus")){
    sFocus = true;
}
    console.log('check result ' + sFocus);
    return sFocus;


Notes:
  • snippet name is subjectiveSnippet
  • focus field has a CSS class of subjectiveField
Photo of Griffin Brown

Griffin Brown

  • 2,766 Points 2k badge 2x thumb
  • like a novice

Posted 2 years ago

  • 1
Photo of Griffin Brown

Griffin Brown

  • 2,766 Points 2k badge 2x thumb
bump
Photo of Shmuel Kamensky

Shmuel Kamensky, Champion

  • 4,328 Points 4k badge 2x thumb
Can you go with a custom field renderer? 

I noticed that the html for each field's UI element is available for modification.

e.g . something like this (may have to mess around with the object hierarchy)

var field = arguments[0];
$ = skuid.$;


$(field.element).on('focus',function(){console.log('You have focused on me');});