It would nice to be able to add classes to a views/scenes/fields in the builder. We are able to do by adding a span in the title or description and using the selectors ‘.kn-view:has(.class)’ or ‘.kn-input:has(.class)’ which has caused us issues and it also makes the CSS tedious. I believe this feature would save a lot of time when trying to style our app use jquery.
I had also requested t his many months ago. Brad - can you show an example of what you are putting in the View Description. I don’t understand how this is going to work - the span doesn’t envelope the view?
I tried this and it doesn’t work for me. I must be missing something. When you say ‘View Description’ - are you referring to the box labeled Description on the Settings tab of the View dialog box (used to create the view)? If so, how does this apply to the app - it doesn’t show up in the html? If this is not what you are referring to, please provide more details of where this code is placed.
Craig - I now see where the Description shows up in the HTML. However, I do not see the CSS show up anywhere in the view. Even if it were to get overwritten by another higher priority CSS, it should still show up and show it disabled.
An example is that I use jquery to add a class to certain views where I want the presentation or behavior to be different than the default, or I add a class to various input fields to hide them off-screen so that I can update them via code when a form is submitted, etc.
The other thing I do a lot is set CSSto make forms look better - more professional and readable. In the CSS, I have to list every form view that I want to include. Otherwise I would need to use javascript to add a class - which sometimes causes some glitches/flashes upon loading the page. In addition I would need a handler for every form view.
I finally got around to trying this again. Long story short - I came across an article on the internet that explained that this feature - :has() - is not enabled by default in Firefox - you have to enable it. It works fine in native Chrome. This would certainly provide for a significant reduction in CSS, however, unless I can find a way to force Firefox (and any other browsers that require enabling), I can’t rely on using this technique in client apps.
It allows you to add keywords in view descriptions in the builder amongst other things.
One of the keywords is _cls
Which you could use like this
_cls=your-class
This will add the class to your view which can then be used in CSS. Unfortunately to get most CSS to work in Knack :has or using JQuery is the only solution.
If you decide to use the KTL (knack-toolkit-library) I can help with any questions you have about it.
Since we started to use KTL our CSS is so much easier and cleaner to write.