Rebind after ajax is complete

Question!

I am currently in the process of working on the app which is through modular pattern.

The problem i am currently getting is that once the Ajax is complete, i want to be able to fire a function within the object. The object i can see but when i specify a function, it fails and comes back as Undefined.

JS

var TestCase = {
  settings: {
    cu: $('.select'),
  },

  init: function() {
    se = this.settings;
  },

  windowsReady: function() {
    TestCase.init();
    if ($.fn.selectBox) {
      TestCase.selectBind();
    }
  },

  ajaxComp: function() {
    TestCase.init();
    TestCase.selectBind();
  },

  selectBind: function(){
    se.cu.selectBox();
  },

};

JS Fire - The selectBind works fine when its loaded through the ready call. However as mentioned before, the ajaxcomplete keeps coming back as Undefined for TestCase.ajaxComp(); or a direct call for TestCase.selectBind(); Please note that when i console.log(TestCase) it lists all the objects.

$(document).ready(function () {
  TestCase.windowsReady();
});

$(document).ajaxSuccess(function() {
  console.log(TestCase);
  TestCase.ajaxComp();
  console.log('completed');
});


Answers

This is happenning because of this line:

se = this.settings;

The this in the scope of your $(document).ajaxSuccess(...) method will be the jQuery object, not TestCase object.

Try changing it to se = TestCase.settings;



I believe that, alternatively to the suggestions you already recieved, you might want to try the following. Using logicals is probably one of the best options for such a problem, since you don't need to use for-loops:

function out = clear_matr(A)
    % ind is true for all the rows of A, where the highest value is not equal to 1
    ind = ~(max(A, [], 2) == 1);

    % filter A accordingly
    out = A(ind, :);
end
By : merch


Subtract the julian day integer of the earlier date from the julian integer of the later date. The following tells you exactly how to do that.

http://www.cs.utsa.edu/~cs1063/projects/Spring2011/Project1/jdn-explanation.html

Otherwise, http://pdc.ro.nu/jd-code.html already has a C version

long gregorian_calendar_to_jd(int y, int m, int d)
{
    y+=8000;
    if(m<3) { y--; m+=12; }
    return (y*365) +(y/4) -(y/100) +(y/400) -1200820
          +(m*153+3)/5-92
          +d-1;
}


This video can help you solving your question :)
By: admin