Tuesday 15 May 2012

javascript - empty() and then append() gives a blinking effect -



javascript - empty() and then append() gives a blinking effect -

i have code

$.ajax({ type: "post", url: "display.aspx/getschedules", data: '{"_facilityid":"' + facilityid + '", "_facilitytime":"' + m + '", "_facilityoffset":"' + os + '", "_facilityclock":"' + facilityclock + '", "_facilitydisplaypastevents":"' + facilitydisplaypastevents + '"}', contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { $("#myschedule").empty().append(data.d); }, error: function (data) { toastr.error("error in getschedules"); } });

actually, fetching info server , re-drawing table. redrawing takes place in webmethod. since using empty() function , appending markup table i.e. redrawing table, highlighted in table, seems go blank second, , highlights back.

is there improve way this? thanks

anyone interested in webmethod, here is:

[webmethod] public static string getschedules(string _facilityid, datetime _facilitytime, string _facilityoffset, string _facilityclock, bool _facilitydisplaypastevents) { if (_facilityid == string.empty) homecoming string.empty; if (_facilitytime == null) homecoming string.empty; using (livein5entities context = new livein5entities()) //using opens/closes db , manages { int facilityid = convert.toint16(_facilityid); var facility = context.facilities.where(u => u.facilityid == facilityid && u.active == true).firstordefault(); var facility_location = context.locations.where(u => u.locationid == facility.locationid).firstordefault(); datatable schedules = getallschedules(_facilityid, _facilitytime, _facilityoffset, _facilitydisplaypastevents); var schedulehtml = "<table class='scheduletable'>"; var index = 1; foreach (datarow item in schedules.rows) { datetime starttime = datetime.parse(item[2].tostring()); datetime endtime = datetime.parse(item[3].tostring()); starttime = starttime.addhours(-8); endtime = endtime.addhours(-8); schedulehtml += "<tr id='fsid_" + index + "' class='scheduleitem'>"; schedulehtml += " <td class='time'>"; if (_facilityclock == "24") // check if user has selected 24 hours or 12 hours. { schedulehtml += " <div class='starttime'>" + starttime.tostring("hh:mm") + "</div>"; schedulehtml += " <div class='endtime'>" + endtime.tostring("hh:mm") + "</div>"; } else { schedulehtml += " <div class='starttime'>" + starttime.tostring("h:mm tt") + "</div>"; schedulehtml += " <div class='endtime'>" + endtime.tostring("h:mm tt") + "</div>"; } schedulehtml += " </td> "; schedulehtml += " <td class='guest'>"; schedulehtml += " <div class='guestname'>" + item[4].tostring() + "</div>"; schedulehtml += " <div class='topic'>" + item[5].tostring() + "</div>"; schedulehtml += " </td>"; schedulehtml += " <td class='eventdetails'>"; schedulehtml += " <div class='eventname'>" + item[6].tostring() + "</div>"; schedulehtml += " <div class='host'>" + item[7].tostring() + "</div>"; schedulehtml += " </td>"; schedulehtml += "</tr>"; index++; // increment id number - index } schedulehtml += "</table>"; homecoming schedulehtml; }

javascript c# jquery asp.net

No comments:

Post a Comment