Drupal.behaviors function can't detect Views object when user is Anonymous Goals:
1. have a button in a View that refreshes that View via AJAX on click event.
2. Load refresh script only on pages that have View named "my_view".

I was able to achieve both of the following with the code shown below. 

template.php  

function mytheme_preprocess_views_view(&amp;$variables) {
  $view = &amp;$variables['view'];
  // Make sure it's the correct view
  if ($view-&gt;name == 'products_left_in_stock') {  //EDITED
    // add needed javascript
    drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/views-refresh.js');
  }
}


viewsrefresh.js

(function ($) {
    Drupal.behaviors.myViewsRefresh = {
    attach: function( context , settings) {

        var viewName = 'products_left_in_stock';

        // View is Ajax enabled,
        // and is available as a property of the Drupal object
        // like so...
        var instances = Drupal.views.instances;
        var targetedView;

        // iterate thru the various
        // views instances name to find your views
        $.each( instances , function getInstance( index, element){
                    if(element.settings.view_name == viewName ){
                            targetedView = '.view-dom-id-' + element.settings.view_dom_id;
                    }
        });

        // Define your button click here...
        $('.viewsrefreshbtn').click( function(){
                if(typeof targetedView !== 'undefined'){
                    $(targetedView).trigger('RefreshView'); 
                    console.log ('Clicked refresh btn on view. View Refreshed');
                }
                else {console.log ('Can\'t find viewName on this page');}
        });            
    }
}
})(jQuery);


refresh button added to Views footer in Global Text 

&lt;div class="viewsrefreshbtn"&gt;refresh&lt;/div&gt;


ISSUE IS: Refresh button works only for logged in users. When Anonymous user clicks Refresh button - following line from viewsrefresh.js executes 

else {console.log ('Can\'t find viewName on this page');}


and nothing else happens.
Targeted View is present on a page and markup generated for that view is exactly the same as for logged in users. Seems like my function can not find the view when user is not logged in.

QUESTION: How can I make this function to detect targeted view when the user is not logged in? Am I missing something fundamental?

I understand this is a lengthy question. Greatly appreciate any insight on this if anybody has time to spare. thanks
I found that solution that works for me even under anonym.
Stars - changes

(function ($) {
    Drupal.behaviors.myViewsRefresh = {
    attach: function( context , settings) {

        **var viewName = 'ajax_test';**

        // View is Ajax enabled,
        // and is available as a property of the Drupal object
        // like so...
        **var instances = settings.views.ajaxViews;**
        var targetedView;

        // iterate thru the various
        // views instances name to find your views
        $.each( instances , function getInstance( index, element){
                    if(**element.view_name** == viewName ){
                            targetedView = '.view-dom-id-' + **element.view_dom_id**;
                    }
        });

        // Define your button click here...
        $('.viewsrefreshbtn').click( function(){
                if(typeof targetedView !== 'undefined'){
                    $(targetedView).trigger('RefreshView'); 
                    console.log ('Clicked refresh btn on view. View Refreshed');
                }
                else {console.log ('Can\'t find viewName on this page');}
        });            
    }
}
})(jQuery);