When I saw the question and answer from :
I want to ask.
Is the replacement syntax as in the question (using normal jQuery) :
$(document).ready(function () {
$("#Div1").click(function () {
alert("Hello world!");
});
});
And replaced as in section in bbUI :
ondomready: function(element, id) {
if (id == 'home') {
$("#Div1").click(function () {
alert("Hello world!");
});
}
}
Did not cause long syntax in index.htm file ???
Because I know the syntax above is at index.htm when using bbUI lib
If only doing alerts on syntax above is not visible. When using a lot of lines of code on a page whether it should be incorporated into index.htm like the statement above?
How if i use my sample code :
$("#DropDownList2").hide();
$("#pertama").change(function () {
if ($("#pertama option:selected").text() == "- Pilih Data -") {
$("#DropDownList2").hide();
$("select[id$=DropDownList2] > option").remove();
}
if ($("#pertama option:selected").text() == "Keren") {
$("#DropDownList2").show();
$("select[id$=DropDownList2] > option").remove();
$("#DropDownList2").append($("<option>" + ("Hyderabad") + "</option>"));
$("#DropDownList2").append($("<option>" + ("Vijayawada") + "</option>"));
$("#DropDownList2").append($("<option>" + ("Karimnagar") + "</option>"));
}
if ($("#pertama option:selected").text() == "Jelek") {
$("#DropDownList2").show();
$("select[id$=DropDownList2] > option").remove();
$("#DropDownList2").append($("<option>" + ("Madhurai") + "</option>"));
$("#DropDownList2").append($("<option>" + ("Chennai") + "</option>"));
}
if ($("#pertama option:selected").text() == "Tidak Tahu") {
$("#DropDownList2").show();
$("select[id$=DropDownList2] > option").remove();
$("#DropDownList2").append($("<option>" + ("Bangalore") + "</option>"));
}
});
Would look very much code in the main file
Is the only way out was to use a function in jQuery?
If I understand your question correctly…
You can keep the main file clean by having functions declared for each page load. Store your functions in separate js files.
…
This is what I do in my app.