Yii Framework Forum: Prevent Listview updates - Yii Framework Forum

Jump to content

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

Prevent Listview updates Prevent ListView pager from updating on Disabled and Active links Rate Topic: -----

#1 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 02 August 2012 - 02:31 AM

This will prevent ListView's from firing updates when the user clicks on the pager's disabled or active links. Useful when you have a fancy effect, like an overlay with an animated gif, to transition to the new result set.

You'll probably want to copy jquery.yiilistview.js to a new location, modify it, and point to the script file OR extend CListView and change baseScriptFile to point to the new file.

    $.fn.yiiListView = function(options) {
        return this.each(function(){
            var settings = $.extend({}, $.fn.yiiListView.defaults, options || {});
            var $this = $(this);
            var id = $this.attr('id');
            if(settings.updateSelector == undefined) {
                settings.updateSelector = '#'+id+' .'+settings.pagerClass.replace(/\s+/g,'.')+' a, #'+id+' .'+settings.sorterClass.replace(/\s+/g,'.')+' a';
            }
            $.fn.yiiListView.settings[id] = settings;

            if(settings.ajaxUpdate.length > 0) {
                $(settings.updateSelector).die('click').live('click',function(){
	    	
                    // HERE!!!
                    // HERE!!!
                    // HERE!!! 
                    // Prevents disabled or active class from firing the ajax update
                    if ($(this).parent().is('.disabled, .active')) {
                        return false;
                    }          
          
                    $.fn.yiiListView.update(id, {
                        url: $(this).attr('href')
                    });
                    return false;
                });
            }
        });
    };


Matt
0

#2 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 03 August 2012 - 05:40 AM

View Postwaterloomatt, on 02 August 2012 - 02:31 AM, said:

You'll probably want to copy jquery.yiilistview.js to a new location, modify it, and point to the script file OR extend CListView and change baseScriptFile to point to the new file.

OR you can just override original function with own version - create another js file and include it after the original list view script. In your script you can replace function with your version:
...
$.fn.yiiListView = function(options) { //my version }
//my other code

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