I’ve created a new way to set the title of your browser tab depending on the current scene. The nice thing is it keeps all of the code together, rather than spread out in the various scene-render events throughout your code. And since events can have multiple handlers you don’t need to worry about this overwriting any existing scene-render code you have elsewhere.
In the code below scene_titles uses scene number for the key, and tab title for the value. And you can have dynamic text by making the value a function.
I imagine some folks prefer having each scene-render begin with assigning document.title as a way to track which scene it is. But I have quite a few scenes in my app and many don’t need custom code besides the tab title.
I agree—I’ve started writing my handlers dynamically (as shown) whenever possible and it definitely feels cleaner than seeing scene-render a bunch of times.
Thanks for sharing. Sometimes loading a library is overkill when a snippet will do, but in any case, it definitely looks cool, and great that you made it open-source.
FWIW Normand I took a look at your library and think it could be useful for a large company/application. I really like the idea of grabbing local files to make development much faster. It always feels weird copying+pasting a few hundred/thousand lines of code into Knack.
@Dean2 You’re absolutely right, and I know that this is the reason why no one seems to be interested in the KTL. It’s like killing a mosquito with a light saber!
But I’ve just completed a major simplification process: it’s now only 5 lines of Javascript code to copy, and no more CSS. All the complexity is hidden, yet visible to those who want to see the code. The minified code is currently at 125KB with an average load time around 200ms, which is quite negligible imo.
When I compare the minified/formatted Javascript code from Knack vs KTL, they have 137090 lines of code vs 4300 lines for the KTL - a drop in the bucket. They also use several libraries, like jQuery, FullCalendar, Highcharts, Sortable, Backbone, Moment, Bootstrap, Underscore, Lodash, Vue and more. So KTL would be just a small one among several others.
Usually, people are only interested in one or two features of the KTL, but once it’s installed and they see all what they get, I’m sure they will enjoy them. It not, it’s possible to turn off whatever you don’t like.
Does anyone know how to get this bit of code to work? I assume you can’t just copy and paste it into the Javasript section, I tried this and it had no effect on the name of the tabs in the browser. Thanks Anthony
Hey @AnthonySar57194, you’ll need to update the scene numbers to ones relevant to your app. Start by opening Knack’s builder and going to the page/scene that you want a new title for. The browser URL for that page will look something like https://builder.knack.com/ your_account/your_app/pages/scene_123. The number at the end is what you need. Then update the code so that scene_titles includes the scene number as a key and the title as the value.
I like the KTL code you have put together but I have a issue. On a Iphone if you have a numbers field it goes to the number keyboard on the Iphone and their is no decimal. Can this be turned off?
I look threw all you get hub stuff and can not seem to figure it out.
We have a Maintenance program built in knack with Technicians in the field using their phones. But staff in the back that really could benefit from KTL. But Time is money and in are case a decimal point is important.
Again sorry for asking here. I tried Get Hub but it never seemed to get across. I probably did something wrong . Saw you had a recent post here so just going for it.
Thanks