Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Yii Renderpartial Problem

$
0
0
Hello every1,

i have a problem with understanding renderPartial. I have one view, that renders 2 more views inside view JS.

...
<div id="data"></div>
<div id="dayData"></div>
...
	$.post('/hr/userDeployment/shippingDeploymentCalendar', {date: date,YII_CSRF_TOKEN:token}, function(data) {
		$('#data').html(data);
    });

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

	function previousMonth(user_id) {
			date = date.previous().month();
	        $.post('/hr/userDeployment/shippingDeploymentCalendar', {date: date.toString('yyyy-MM-dd'),YII_CSRF_TOKEN:token}, function(data) {
	            $("#data").html(data);
	        });
	        $("#currentdate").html(date.toString('MM.yyyy'));
	}

	function nextMonth(user_id) {
		date = date.next().month();
        $.post('/hr/userDeployment/shippingDeploymentCalendar', {date: date.toString('yyyy-MM-dd'),YII_CSRF_TOKEN:token}, function(data) {
            $("#data").html(data);
        });
        $("#currentdate").html(date.toString('MM.yyyy'));
	}

	jQuery(function($) {
		$("#calendar td").click(function(e) {
			if (typeof $(this).attr('id') !== 'undefined') {
				calendarItemClicked(($(this).attr('id')));
				e.stopPropagation();
			}
		});
	});
....


In controller i have 2 functions, that render those 2 views:
	public function actionShippingDeploymentDay() {
		if (Yii::app() -> request -> isAjaxRequest && isset($_POST['date'])) {

			$date = $_POST['date'];

			$criteria = new CDbCriteria;
			$criteria -> condition = 'DATE(fromDate)=DATE("' . $date . '")';

			$dataProvider = new CActiveDataProvider(new UserDeployment, array(
					'criteria' => $criteria,
					'sort' => array('defaultOrder' => 'fromDate ASC'),
					'pagination' => array('pageSize' => 100),
			));

			return $this -> renderPartial('_shippingDay', array('dataProvider'=>$dataProvider,'date'=>$date),false,true);
		}
	}


In this view shippingDeploymentDay i have DateTimePickers. If i add "false,true" at the end, i get errors:
Uncaught TypeError: Object [object Object] has no method 'modal'
Uncaught TypeError: Object [object Object] has no method 'popover'

If i add "false,true" i have no errors, but the Timepickers doesn't work...

Can anyone tell me what i am doing wrong with renderPartial?

[EDIT] In my rendered view i have a button to submit a form:
	<?php
	$this -> widget('bootstrap.widgets.TbButton', array(
			'buttonType' => 'ajaxSubmit',
			'icon' => 'ok',
			'url' => Yii::app() -> createUrl('hr/userDeployment/createShipping'),
			'label' => 'Submit',
			'ajaxOptions' => array('success' => 'function(data){
					Loading.show();
					var obj = $.parseJSON(data);
					if(obj.status=="success"){
					$("#newUserDeployment").modal("hide");
					Loading.hide();
					window.location.href = obj.url;
} else {
					Loading.hide();
					$("#userDeployment-form-error-div").show();
					$("#userDeployment-form-error-div").html("");
					var $inputs = $("#user-time-form :input");
					$inputs.each(function() {
					$(this).removeClass("error");
					$(this).closest(\'div[class^="control-group"]\').addClass("success validating");
});
					for (var p in obj) {
					if(document.getElementById(p)) {
					$("#"+p).closest(\'div[class^="control-group"]\').removeClass("success");
					$("#"+p).closest(\'div[class^="control-group"]\').addClass("error");
}
					$("#userDeployment-form-error-div").append(obj[p]  + "<br/>");
}

}

}'),
	));

	$this -> endWidget();
	Yii::app() -> controller -> widget('bootstrap.widgets.TbButton', array(
			'label' => 'Close',
			'url' => '#',
			'htmlOptions' => array('data-dismiss' => 'modal'),
	));

	$this -> endWidget();
	?>


Allthough "obj.url" is right url, i checked it with alert(obj.url) this function "window.location.href = obj.url;" doesnt redirect me to the URL.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>