public/rails_ext/rails_ext.js in rails-ext-0.2.9 vs public/rails_ext/rails_ext.js in rails-ext-0.2.10

- old
+ new

@@ -87,15 +87,15 @@ } return id; }, first: function(){ - return (this.size() > 0) ? $(this[0]) : null + return $((this.size() > 0) ? this[0] : this) }, last: function(){ - return (this.size() > 0) ? $(this[this.size() - 1]) : null + return $((this.size() > 0) ? this[this.size() - 1] : this) }, blank: function(){ return this.size() < 1 } @@ -149,17 +149,17 @@ }); } }, _processOnceForEveryInitializer: function(definition) { - // var count = 0 + var count = 0 $(definition.query).each(function(){ var e = $(this); if(!e.hasClass(definition.name)){ // if(!e.data(definition.name)){ - // count = count + 1; + count = count + 1; e.addClass(definition.name); // e.data(definition.name, true); - definition.initializer.apply(this); + definition.initializer.apply($(this)); } }); // log(definition.name + ', ' + definition.query + ': ' + $(definition.query).size() + '/' + count) }, @@ -176,9 +176,36 @@ $._processInitializers(); }); $(document).ajaxSuccess(function(){ $._processInitializers(); }); + + +// +// AJAX +// +$.ajaxSetup({ + authenticity_token: $.authenticity_token, + type: "script", + dataType: "script", + format: 'js' +}); + + +// +// dataAttr +// +$.fn.extend({ + dataAttr: function(name, value) { + var attr_name = 'data-' + name; + if(value){ + this.attr(attr_name, value); + }else{ + return this.attr(attr_name); + } + } +}); + // // link_to // $.fn.extend({ \ No newline at end of file