Doesn't work without coffeescript and SASS
TrevorHinesley opened this issue · comments
I forked the project and converted it to CSS/JS for anyone using only those two.
https://github.com/TrevorHinesley/x-editable-rails
Thanks for making this awesome Rails version!
You're welcome :)
How do you handle images in pure CSS?
I believe I can just do /assets/editable/blah.png let me check. Didn't consider that part haha. Also, I'm getting undefined method 'xeditable?' for #<#<Class:0x00000102236b50>:0x0000010b2fd850>
-- what's that from?
Ahhh ya I'm getting a couple obscure errors such as:
Uncaught SyntaxError: Unexpected identifier
in line 12 of my editable_form.js and I'm sure there are others I haven't caught yet. I thought the switch to CSS/JS would be simpler. My bad!
That should work in development, but in production are used digest assets. That's the reason why is used image-url
sprocket helper. Please check Authorization section for xeditable?
undefined method. It's just syntax error, every Coffee is compiled to JS.
I'm using the xeditable? method in my application controller, no luck.
And why wouldn't that work in production?
It's set like helper method? helper_method :xeditable?
Rails create digest version of images as default, so /assets/image.png will not work and will raise error 404 not found.
http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark
I just tried precompiling an app I'm doing on the side where all the url's are assets/whatever, and it worked fine. Hashed filenames and all.
It's ok then :)
Here is my editable_form.js file:
jQuery(function($) {
var EditableForm;
EditableForm = $.fn.editableform.Constructor;
EditableForm.prototype.saveWithUrlHook = function(value) {
var model, nestedId, nestedLocale, nestedName, originalUrl;
originalUrl = this.options.url;
model = this.options.model;
nestedName = this.options.nested;
nestedId = this.options.nid;
nestedLocale = this.options.locale;
this.options.url = (function(_this) {
function(params) {
var myName, myValue, nested, obj;
if (typeof originalUrl === 'function') {
originalUrl.call(_this.options.scope, params);
} else if ((originalUrl != null) && _this.options.send !== 'never') {
myName = params.name;
myValue = params.value;
if (Object.prototype.toString.call(params.value) === '[object Array]' && params.value.length === 0) {
params.value.push("");
}
obj = {};
if (nestedName) {
nested = {};
nested[myName] = myValue;
nested['id'] = nestedId;
if (nestedLocale) {
nested['locale'] = nestedLocale;
}
obj[nestedName + '_attributes'] = nested;
} else {
obj[myName] = myValue;
}
params[model] = obj;
delete params.name;
delete params.value;
delete params.pk;
$.ajax($.extend({
url: originalUrl,
data: params,
type: 'PUT',
dataType: 'json'
}, _this.options.ajaxOptions));
}
};
})(this);
this.saveWithoutUrlHook(value);
};
EditableForm.prototype.saveWithoutUrlHook = EditableForm.prototype.save;
EditableForm.prototype.save = EditableForm.prototype.saveWithUrlHook;
});
Why would I be getting the Unexpected Syntax: Unexpected identifier
issue on line 12 (function(params) {
)?