Just to keep things interesting and close my final open question, the solution that implements the below functionality in a nicely organized manner with a decent architectur
Matpol gave a literal solution to the specific information provided. Your edit implies that you are looking for an answer to a more hypothetical question. In other words, you're looking for the "approach".
Answering the question in this manner; the single example you gave is a bit of a red herring. It is but a single item in the whole app, and prevents us from "seeing the forest from the trees". So what is the Forest? The question, asked as such, doesn't define it. But I think all programmers will agree when I say it's a nightmare to work on a project that has no definition. So, I'll rephrase your question and answer, "What is the process for defining a project?"
Mine is, in fact, asking a series of questions:
A lot of the time, to get to the bottom of those questions, I need to ask other business questions:
Hopefully, these questions will result in a set of foundational code that you can consider your core. Your core, as you suspected, probably doesn't fit the modular approach. And as you identified, you will want to break that core down into a Model / View / Controller layout.
But it's inevitable that you will need to add design fluff. And this brings us back to your code example - its fluff. Fluff belongs in a plugin, separated from the core. This isn't to say that all of your plugins should be delivered to the user in separate js files... but for your development purposes, they should be viewed as modular, and independent from the core code base.