Javascript "for" loop isnt fully executed on the first time -


i developing calendar function displaying database table data in our cms.

i generate calendar table in js. database entries generated in c# , put in array. end result looks this:

var termine = new array(4); termine[0] = {     id:1,     datum:1442912403000,     titel:"test",     detail:"some encoded html" }; termine[1] = {     id:2,     datum:1444306500000,     titel:"testing bit more",     detail:"some encoded html" }; termine[2] = {     id:3,     datum:1442880000000,     titel:"test 2",     detail:"some encoded html" }; termine[3] = {     id:4,     datum:1442932140000,     titel:"test 3",     detail:"some encoded html" }; 

now looping through array in function , add appointments (divs) table:

function addtermine() {     (var = 0; < termine.length; i++) {         var t = termine[i];         var d = new date(t.datum);         d.settime(d.gettime() + d.gettimezoneoffset() * 60 * 1000);         if (d.getfullyear() === currentyear && d.getmonth() === currentmonthint-1) {             var id = d.getfullyear() + "-" + d.getmonth() + "-" + d.getdate();             var longid =  d.getfullyear() + "-" + d.getmonth() + "-" + d.getdate() + "-" + d.gethours() + "-" + d.getminutes();             var hour = d.gethours();             if (hour < 10) hour = "0" + hour;             var min = d.getminutes();             if (min < 10) min = "0" + min;             var s = "<div id=\"ter" + longid + "\" class=\"termin\" onmouseover=\"showdetail(event,'detail" + longid + "');\" onmouseout=\"hidedetail('detail" + longid + "');\">" + hour + ":" + min + "<br>" + t.titel + "</div>";             $("#cont" + id).html($("#cont" + id).html() + s);             $("#ter" + longid).click(function () {                 location.href = window.location.href + "?cid=" + cid + "&col=" + t.id + "&details=1";             });             var detail = "<div id=\"detail" + longid + "\" class=\"hoverdetail\">" + unescape(t.detail) + "</div>";             $("body").append(detail);         }     } } 

the problem when function executed first time (from document.ready) loop executed 1 time tho termine.length 4 in debugger. when execute function after changing months load months appointments executes correctly.

if point me towards why doesnt execute correctly on first try i'd grateful.

i testing on our dev website feel free debug it.

your first calendar element adds dom <script> element url /xtend/javascript/messages_de.js. when script loaded browser causes javascript error

$.validator undefined

this javascript error causes further javascript processing halt. there race condition there also, javascript continues before bad script loaded , in case 4 new div's on calendar.

the error occurs because newly injected javascript code attempting use jquery validate plugin, you've not included.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

node.js - Express and Redis - If session exists for this user, don't allow access -

excel - I can't get the attachement of the email PHP -