, когда я связываю пользовательский плагин таким образом, он работает нормально:
<script type="text/javascript">
$("#MyGrid").customFilter({ postUrl: '@(Url.Action("SearchOffers", "Department"))' });
</script>
но если я хочу подождать, пока документ не будет готов:
<script type="text/javascript">
$(document).ready(function() {
$("#MyGrid").customFilter({ postUrl: '@(Url.Action("SearchOffers", "Department"))' });
});
</script>
$ ("# MyGrid"). CustomFilter - это не ошибка функции. Почему?
Пользовательский плагин:
(function ($) {
var theGrid;
var filterTimeout;
var mouseIsInside = false;
var postUrl;
var methods = {
init: function (options) {
return this.each(function () {
postUrl = options.postUrl;
theGrid = $(this);
...
});
},
method2: function () {
// ...
}
};
$.fn.customFilter = function (method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.customFilter ');
}
};
//private functions
function isFilterable(th) {
var name = th.children("a").text();
return (name.length > 0) ? true : false;
}
...
})(jQuery);