How to make html and UI related javascript code less coupled?
<p>There are usually some code to initialize the UI component. For example, need to setup some ui in <code>document.ready</code> or <code>bind</code> events to UI.  </p>

<p>From my understanding, we should not put these code in html file. But my concern is if I put these init code to a separate js file, it seems that it is still highly coupled to the html file as I need to hard code the UI class/id in order to select it. <strong>What is the usual practice/architecture to decouple html and UI related javascript?</strong> It is good if you can provide some simple example.</p>

<p><strong>view.js</strong>  </p>

<pre><code>function init() {
    $("#some_view").click(sth);
    $("#some_view").text(sth);
}
</code></pre>
