Yii Framework Forum: Proper Way To Use Yiigridview.update() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Proper Way To Use Yiigridview.update() Rate Topic: -----

#1 User is offline   jsasitorn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-February 13

Posted 27 February 2013 - 11:19 PM

What is the proper way to use the yiiGridView.update() function? and/or is there any documentation regarding the execution model? Here is a snippet that I found online that is a typical way to code an ajax update for a grid.

		$('#item-grid a.submitable').live('click',function(){
			$.fn.yiiGridView.update('item-grid', {
				type:'POST',
				url:$(this).attr('href'),
				data: {'".Yii::app()->request->csrfTokenName."':'".Yii::app()->request->csrfToken."'},
				success:function() {
					$.fn.yiiGridView.update('item-grid');
				}
			});
			return false;
		})


As you can see there is an outer update() called via POST, but then there is an inner update() called with an implicit GET. Why is there a redundancy here? I was auditing my server logs , and it show a POST request and two GET requests. Removing the success clause, leaving only the outer update() call still produces the necessary AJAX requests from what I can tell..

		$('#item-grid a.submitable').live('click',function(){
			$.fn.yiiGridView.update('item-grid', {
				type:'POST',
				url:$(this).attr('href'),
				data: {'".Yii::app()->request->csrfTokenName."':'".Yii::app()->request->csrfToken."'},
			});
			return false;
		})


Thanks,
James
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users