0

i am a bit pissed off JS and CSS registration by renderPartial. I have a problem that i have following view:

<div id="data"></div>
<div id="dayData"></div>

Then i have following scripts in footer:

$.ajaxSetup({async: false});

$("#currentdate").html(date.toString('MM.yyyy'));
$.post('userDeployment/shippingDeploymentCalendar', {date: date.toString('yyyy-MM-dd'),YII_CSRF_TOKEN:token}, function(data) {
    var ni = document.getElementById('data');
    ni.innerHTML = data;
});

function calendarItemClicked(id) {
    $("table#calendar td.calendar-current-day").addClass("calendar-day");
    $("table#calendar td.calendar-current-day").removeClass("calendar-current-day");
    $("table#calendar td#"+id).addClass("calendar-current-day");

    if(id<10)
        id = "0"+id;
    $.post('userDeployment/shippingDeploymentDay', {date: date.toString('yyyy-MM')+"-"+id,YII_CSRF_TOKEN:token}, function(data) {
        $("#dayData").html(data);
        var details = $("table#calendar td#"+id+" div.calendar-text").text();
        var substr = details.split(' / ');
        $("#dayDetails").html(need+": "+substr[1]+"<br/>"+planned+": "+substr[0]);
    });
}

Now when the page is loaded everything looks ok, but the JQuery doesnt work? When i change the ni.innerHTML = data; to $('#data').setHTML(data); - then it works again, but another JQuery function from this HTMl doesnt work...?

Kai
  • 38,985
  • 14
  • 88
  • 103
ekussberg
  • 559
  • 1
  • 8
  • 19
  • i think you have problem with your script. have you tried to use all scripts in (function($) {})(jQuery) ? – sanj Feb 27 '13 at 10:37
  • i had this part of code: jQuery(function($) { $("#calendar td").click(function(e) { if (typeof $(this).attr('id') !== 'undefined') { calendarItemClicked(($(this).attr('id'))); e.stopPropagation(); } }); }); in my Calendar Widget i have a JS file, that i register when the widget is called. Now i copied this small part of code to my View and it is working... – ekussberg Feb 27 '13 at 10:48

0 Answers0