Giter Site home page Giter Site logo

werein / x-editable-rails Goto Github PK

View Code? Open in Web Editor NEW
155.0 9.0 87.0 434 KB

Edit fields easily with X-Editable helper

Home Page: https://wereinhq.com/guides/x-editable-rails

License: MIT License

Ruby 81.89% CoffeeScript 1.90% CSS 1.53% HTML 14.67%
rails x-editable inline-editor bootstrap bootstrap3

x-editable-rails's Introduction

X::Editable::Rails

Build Status Code Climate Test coverage Version Dependencies

X-editable for Rails

Live demo

Checkout live demo here

Installation

Add this line to your application's Gemfile:

gem 'x-editable-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install x-editable-rails

Usage

Assets

Choose between the following javascripts:

  • bootstrap-editable
  • bootstrap2-editable
  • jqueryui-editable
  • jquery-editable-poshytip

You'll also need to include editable/rails in your scripts for this to work.

#= require editable/bootstrap-editable
#= require editable/rails

Choose the corresponding stylesheets:

  • bootstrap-editable
  • bootstrap2-editable
  • jqueryui-editable
  • jquery-editable
// as CSS
*= require editable/bootstrap-editable

// or SCSS
@import "editable/bootstrap-editable";

Enable editing with jQuery:

$('.editable').editable()

For custom inputs like the Wysihtml5 editor, add these dependencies:

#= require editable/bootstrap-editable
#= require editable/inputs-ext/wysihtml5
#= require editable/inputs-ext/bootstrap-wysihtml5
#= require editable/inputs-ext/wysihtml5-editable
#= require editable/rails

And related stylesheets:

//= require editable/bootstrap-editable
//= require editable/inputs-ext/bootstrap-wysihtml5
//= require editable/inputs-ext/wysiwyg-color

Making Things Editable

x-editable-rails provides a helper method in your view to make your model values editable. By default, you need to specify the model and property that should be editable. A span element is rendered with data-* attributes used by x-editable.

# the editable object and the attribute to edit
%h1= editable @model, :name

You can customize the tag name and title attribute:

  • tag - span by default.
  • title - The model and attribute name are used to create a capitalized title

The editable helper method automatically adds these data-* attributes used by x-editable.

  • url - Uses the polymorphic_path(model) helper method.
  • source - Only populated if the value is a boolean to convert true or false to "Yes" and "No".
  • value - Uses model.name. If model.name were a boolean value or if a source is specified, the source text would be displayed rather than the raw value. (Presumably the value is an ID and the source would have the text associated with that value.)
  • placeholder - Uses the title value by default
# editable object, what_you_want_update, e: exception - when is xeditable? false or can? :edit, object is false
%h1= editable @model, :name, url: model_path, value: @model.name.upcase

Here are some special features to enhance what's baked into x-editable:

  • type - The type of input is automatically detected. By default, if the value is a boolean, the type is "select" with a built-in source that outputs "Yes" and "No" (unless another source is specified).
  • source - In addition to hashes or arrays of hashes, you can also use an array of strings for a simpler structure if the name and value are the same:
source = [ "Active", "Disabled" ]
editable @model, :enabled, source: source
  • value - This option will override the model.name value
  • classes - This is a custom option for x-editable-rails that will change the editable element's CSS class based on the selected value. Use the source hash structure to map a CSS class name to a value. (This functionality is toggled when the value changes and the "save" event is triggered.)
source  = [ "Active", "Disabled" ]
classes = { "Active" => "label-success", "Disabled" => "label-default" }
editable @model, :enabled, source: source, classes: classes, class: "label"
  • nested - Name of a nested attributes (such as globalize's translations)
  • nid - ID of the nested attribute
%h1= editable @model, :name, nested: :translations, nid: @model.translation.id

# example of nested resource
%h1= editable [picture.gallery, picture], :name, nested: :translations, nid: picture.translation.id

Authorization

Add a helper method to your controllers to indicate if x-editable should be enabled.

def xeditable? object = nil
  true # Or something like current_user.xeditable?
end

You can use CanCan and checks the :edit permission for the model being edited.

def xeditable? object = nil
  can?(:edit, object) ? true : false
end
  • e - Specify a custom (error) message to display if the value isn't editable

"Don't Repeat Yourself" Templates

To make your views cleaner, you can specify all your options for each class and attribute in a YAML configuration file. Attributes where the title or placeholder are not different except maybe capitalized can be left out because they are automatically capitalized when rendered (see above).

This example uses the MailingList class and its attributes. The attribute value can be a string, which is used as the title and placeholder. If you want to specify other options, create a hash of options.

Install configuration file like this: rails g x_editable_rails:install, this step is not necessary

class_options:
  MailingList:
    # Specify placeholder text for each attribute or a Hash of options
    name: Mailing list name
    enabled:
      type: select
      source:
        - Active
        - Disabled
    reply_email:
      type: email
      title: Reply-to email
  User:
    email:
      type: email
    password:
      type: password
    mailing_lists:
      type: select
      # specify a URL to get source via AJAX (see x-editable docs)
      source: <%= ::Rails.application.routes.url_helpers.mailing_lists_source_path %>

Now you can specify your editable fields without options because they will be inherited from your YAML config.

model = MailingList.new

editable model, :name    # type: "text",   title: "Mailing list name"
editable model, :enabled # type: "select", title: "Enabled", source: [ "Active", "Disabled" ]

Examples

Gem also contains demo application with integrated x-editable

cd test/dummy
rake db:migrate
rake db:seed
rails g x_editable_rails:install # optional, it generate config example
rails s

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

x-editable-rails's People

Contributors

13k avatar adamico avatar atwam avatar bteitelb avatar ersatzryan avatar eyupatis avatar jirikolarik avatar joelvh avatar k-s-a avatar klaffenboeck avatar laserlemon avatar mattslack avatar mendelk avatar mengqing avatar mlt avatar quinnharris avatar retani avatar ysjwang avatar zubb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x-editable-rails's Issues

Can't understand how to use this

Sorry guys, but I can't understand this line in the docs

%h1= editable @model, :name

How am I supposed to use this inside a .html.erb view ?

Let's assume I have a h1 element I want to make x-editable in the view. What should I do ?

Control popover placement for wysihtml5 input

Hi!

Is that possible? At the moment it seems to be hardcoded to the right, making the popover invisible when container's width is full page. I could not find a way to set that placement in the docs.

Thanks for your answer and for the great work!

Errors with BS4

After upgrading to bootstap 4 I am working through a few new issues. When I click on the x-editable link the popup appears, but with no content. And, the following error appears in the console. Have you experienced this, will there be a BS4 version of this gem?

TypeError: undefined is not an object (evaluating 'this.tip().addClass')

This error occurs when using editable/bootstrap-editable. If I use 'jqueryui-editable' I get a different error: TypeError: undefined is not an object (evaluating 'this.container()._off')

Environment: Rails 5.0.0, x-editable-rails version 1.5.5, jquery-ui-rails -v 5.0.5, jquery-rails -v 4.1.1. Bootstrap -v 4.0.0.alpha3.

thanks

TypeError: undefined is not an object (evaluating '$.fn.popover.Constructor')

I'm upgrading from bootstrap 3 (was using the bootstrap-sass gem) to BS4 using the bootstrap-rubygem gem. One snag I haven't been able to track down and fix is "TypeError: undefined is not an object (evaluating '$.fn.popover.Constructor')". This error appears in the console as an error on page load---and, breaks all my scripts. I'm wondering if you have any insight on how to fix this----and, perhaps I can contribute my fix towards the BS4 version of this gem. Thanks.

wysihtml5 not working

Also on the wysihtml5 it doesnt work at all Im getting lots of errors

Use of Mutation Events is deprecated. Use MutationObserver instead. bootstrap3-wysihtml5.js:5
TypeError: b.nativeSelection is null bootstrap3-wysihtml5.js:4
NS_ERROR_FAILURE: bootstrap3-wysihtml5.js:7

It seems to time out

Select uses value instead of text as display

In order for xeditable to display select values properly, the element being used (span by default) should not have any content in it, and xeditable will generate the value based on the data-value and the data-source.

However, because x-editable-rails will generate content in every element-type case, we end up seeing the value and not the text. (So if the data-source is [{text: "Male", value: "male"}, {text: "Female", value: "female"}], and the data-value is male, we end up seeing male, and not Male).

This behavior is defined here

too much recursion

too much recursion editable_form.js:6
too much recursion editable_form.js:13

Im getting this error on the first load of the page. If I refresh the page it works fine

I have in my coffee script

$(document).ready ->
$(".editable").editable()
return

Can anyone else advise if this is an issue or something I have done

Also on the wysihtml5 it doesnt work at all Im getting lots of errors

Use of Mutation Events is deprecated. Use MutationObserver instead. bootstrap3-wysihtml5.js:5
TypeError: b.nativeSelection is null bootstrap3-wysihtml5.js:4
NS_ERROR_FAILURE: bootstrap3-wysihtml5.js:7

several fields in dialog

Hi!

original js extention supports multiple fields for i-place editing (see "Custom input, several fields" demo). Any ideas how to achieve this with your gem?

Missing js depedency: moment.js

I tried to use type: :combodate and got on my js console: "moment is not defined".

To solve I needed to download https://momentjs.com/ and then add the dependency at application.js
//= require moment-with-locales.min

Is this on purpose due licensing issues or something? Shouldn't it be on the README?

Display value from ajax after save

How display actual value from response ajax. For example user enter text with space but after save server split space but on view it still display with space

Allow configuration of display text within content_tag

At the moment the value option is used to generate the content within the content_tag output, however, I find myself often wanting to display cropped or truncated content i.e.

<span class="editable" value="Once upon a time in the west.">Once upon a time....</span>

I'd like to propose either a new option to the edtiable() helper to allow configuration of this:

<%= editable @book, :title, display: @book.title.truncate(10) %>

Or perhaps allow the passing of a block which is yielded within the content_tag.

<%= editable @book, :title do %>
    <%= @book.title.truncate(10) %>
<% end %>

Anyone have thoughts on this? I'd be happy to look at putting a PR together unless there are objections to this kind of behaviour in the helper?

X-editable checklist which creates associations with another model

This gem has been amazing. I'm using x-editable to implement an asynchronous editing form in one of my apps.

In my models I have, CommonApp which has_many Industries.

What I would like to do is to create an x-editable checklist, which will associate the common_app to the industries that the user checks.

So far, I've been able to edit the CommonApp's values, such as cover_letter, like so -

        == editable @common_app, :cover_letter, url: user_common_app_path(@user,@common_app), value: @common_app.cover_letter, defaultValue: "Your cover letter hasn't been filled in yet, click here to fill it out!", type: "textarea"

and

  def update
    @common_app = CommonApp.find(params[:id])
    if @common_app.update_attributes(common_app_params)
       render json: {success: true}
    else
       render json: {errors: @common_app.errors}, status: 400
    end
  end

However, I'm not sure where to begin with creating the checklist. Write now, I wrote -->

== editable @common_app, :industry_ids, url: user_common_app_path(@user,@common_app), type: "checklist"

javascript:
  $(function(){
      $('.editable').editable({
          value: [2, 3],    
          source: [
                {value: 1, text: 'option1'},
                {value: 2, text: 'option2'},
                {value: 3, text: 'option3'}
             ]
      });
  });

But I'm not able to get those values to show up.
What way should I go about this?

Just see loading gif when clicking on an editable

I have followed the instructions in the front page. When I click on a editable I only see the loading gif and nothing else. From looking at my logs it doesn't seem to be trying to make a request to anything.

My model responds to JSON and I tested the view to confirm it.

What should I try doing?

Release time?

Guys I have spent a lot of time for debugging my problem in code like this:

editable region, :country_id, source: countries.map { |country| { value: country.id, text: country.name } }, value: region.country.name

In release v1.5.5 it works incorrect, when i click on field, he doesn't find value in sources array...
But in master tree here it works really great with Rails 5.0.5.

May be its time for new release?

Reset X-editable class after save

I'm using x-editable to allow the user to associate itself to another model. The styling changes based on what type of model the user is associated to.

Right now, it works, but the css class only changes after I refresh the page.

How would I go about resetting the css class, after x-editable saves the new value?

This is how my input looks like ->

== editable user, :heat_id, url: admin_user_path(user), type: "select", value: (user.heat.level if user.heat), source: Heat.all.map{ | heat | {value: heat.id, text: heat.level} }, class: "#{user.heat.badge if user.heat}"

I'd essentially need to reapply

class: "#{user.heat.badge if user.heat}"

Inline edition not reload new value

Great gem!

Im running on some troubles when I use the inline edition.
I activate the inline edition and it works (almost) I got the request at the server an update my record but could figure out why the inline form don't close. Using the popover works as great.

Im activating the inline edition with:
$.fn.editable.defaults.mode =

Is there any extra trick that I should be aware of?
Thanks

Checklist functionality - Not sure if I'm being thick

Taking the example of #28, the following code works, with 1 issue: The helper correctly displays the city names, however clicking on the names, the selected items are not checked.

editable @common_app, :city_ids, url: user_common_app_path(@user,@common_app), type: "checklist", value: @common_app.cities.map{|city| city.name}, source: City.all.map{ | city | {value: city.id, text: city.name} }

Switching the value to be defined as @common_app.cities.map{|city| city.id } results in the checkboxes being correctly checked, but the initial value displayed on the page is now the list of ids, rather than the cities.

This is somewhat problematic.

I don't know if it's just because it's the end of a long day, or if I'm simply fundamentally misunderstanding how the view helper is written but looking at https://github.com/werein/x-editable-rails/blob/master/lib/x-editable-rails/view_helpers.rb#L75-L78 I'm not seeing an obvious solution.

I'm happy to write the patch (if I'm not being super retarded), if I'm pointed in the right direction.

Broken attributes with HTML content

A link tag created by wysihtml5 has attributes using double quotes:

<a target="_blank" rel="nofollow" href="http://www.example.com">www.example.com</a>

X-Editable will use this code directly in it's "value" attribute, causing the HTML to break (watch out for the quotes):

<span class="editable" data-model="event" data-name="description" data-placeholder="Text" data-type="wysihtml5" data-url="/events/44?locale=de" data-value="test<br>test<br><a target="_blank" rel="nofollow" href="http://www.example.com">www.example.com</a><br><br>abc<br><br>" title="Text">test<br>test<br><a target="_blank" rel="nofollow" href="http://www.example.com">www.example.com</a><br><br>abc<br><br></span>

A simple way to fix this could be base64-encoding the value attribute.

error msg is not working

I have tried rendering it like this:
render :json => "{'errors' : #{@device.errors.to_json}", status: :unprocessable_entity

and
render :json => "{'errors' : #{@device.errors.to_json}}", status: :unprocessable_entity

and

    render :json => @device.errors, status: :unprocessable_entity

All of these gives an error in the javascript console, saying that response.responseJSON is undefined, and error msgs does not render.

[Question] X-editable works on frontend, but no AJAX being sent / database not changing?

Hey there,

Thanks for the awesome gem! I'm trying to integrate this into my project. I got the frontend working (thanks for the tip about adding to the .coffee file). When I click on an editable item, the UI for editing appears, and after I change the content the web page reflects the new content. However, it doesn't look like it's communicating to the Rails server at all? When I reload the page, the object reverts back to its original state. I didn't see any PUT/POST/GET requests on my server log, and no XHR requests in my Chrome network debugger either. Am I doing something wrong?

I have an Appointment model, and one of the attributes is a notes (string). It's set up using resources :appointments in my routes.

In my show page, I have the following:

<%= editable @appointment, :notes, url: appointment_path, value: @appointment.notes %>

Am I missing a configuration somewhere? I'm using the bootsrap3 flavor, with Rails 4

Edit: I also have strong params correctly set up (rails 4)

Thanks!

typeaheadjs error

I have include the js for typeahead

//= require editable/bootstrap-editable
//= require editable/rails
//= require editable/inputs-ext/typeahead-editable
//= require editable/inputs-ext/typeahead

when i click the xeditable

= editable @profile, :hospital, type: 'typeaheadjs'

got a error

Uncaught TypeError: Cannot read property 'name' of null typeahead.js?body=1:1086

Append to documentation regarding in-view HTML/JS activation

It looks like you'll also need to activate the .edtable classes in the HTML view; noob new users (aka myself) might forget this part...might be good to add into the documentation that you'll still need to do something on the view where it's editable, like:

<script type="text/javascript">
$(document).ready(function() {
    $('.editable').editable();
});
</script>

or perhaps even auto-add that (though that would prevent the user from adding additional options...

problem with postgres and boolean

I have postgresql database, as column datatype I'm using json and inside hash I have boolean type. If I use array it stores '0' or '1', but not a boolean, if I use hash {false: "Hide", true: "Show"} and before callback self.content['value'] = @value == 'true' if ['true', 'false'].include?(@value) it saves correctly, but shows as it is null.

Old font awesome icons are used in calendar picker

font-awesome-rails gem pulls newer version than https://github.com/werein/x-editable-rails/blob/master/vendor/assets/javascripts/editable/bootstrap-editable.js#L6110-L6112 expects. We got to replace icon-arrow-left with fa fa-arrow-left or alike. I'm not sure if that is the way to go in the light of fas vs fa in newer font awesome (v5).

For those looking for a quick workaround here is one ugly fix and another, or, alternatively,

$.fn.datepicker.DPGlobal.template = $.fn.datepicker.DPGlobal.template.replace(/icon-/g, "fa fa-");

Error when providing correct input after failed validation

When you have a validation on a field, the validation works fine, but when you try to enter the correct input after that, it complains about a missing route:

<h2>No route matches [PUT] &quot;/function%20(params)%20%7B%20%20%20%20%20%20%20%20var%20myName,%20myValue,%20nested,%20obj;%20%20%20%20%20%20%20%20myName%20=%20params.name;%20%20%20%20%20%20%20%20myValue%20=%20params.value.replace(/(%5Cr%5Cn|%5Cn|%5Cr)/gm,%20%22%3Cbr/%3E%22);%20%20%20%20%20%20%20%20obj%20=%20%7B%7D;%20%20%20%20%20%20%20%20if%20(nestedName)%20%7B%20%20%20%20%20%20%20%20%20%20nested%20=%20%7B%7D;%20%20%20%20%20%20%20%20%20%20nested%5BmyName%5D%20=%20myValue;%20%20%20%20%20%20%20%20%20%20nested%5B%27id%27%5D%20=%20nestedId;%20%20%20%20%20%20%20%20%20%20if%20(nestedLocale)%20%7B%20%20%20%20%20%20%20%20%20%20%20%20nested%5B%27locale%27%5D%20=%20nestedLocale;%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%20%20obj%5BnestedName%20+%20%27_attributes%27%5D%20=%20nested;%20%20%20%20%20%20%20%20%7D%20else%20%7B%20%20%20%20%20%20%20%20%20%20obj%5BmyName%5D%20=%20myValue;%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20params%5Bmodel%5D%20=%20obj;%20%20%20%20%20%20%20%20delete%20params.name;%20%20%20%20%20%20%20%20delete%20params.value;%20%20%20%20%20%20%20%20delete%20params.pk;%20%20%20%20%20%20%20%20return%20$.ajax($.extend(%7B%20%20%20%20%20%20%20%20%20%20url:%20url,%20%20%20%20%20%20%20%20%20%20data:%20params,%20%20%20%20%20%20%20%20%20%20type:%20%27PUT%27,%20%20%20%20%20%20%20%20%20%20dataType:%20%27json%27%20%20%20%20%20%20%20%20%7D,%20_this.options.ajaxOptions));%20%20%20%20%20%20%7D&quot;</h2>

The full error-message from rails is available in this gist

Patching the .editable submit method to allow programmatic submit

I've stumbled upon an annoying issue when I try to write integration tests with Rspec & Capybara to simulate filling in a text area with x-editable.

While I can set the value with the x-editable setValue() method:

$('.editable').editable('setValue', 'foobar')

When I try submitting the form with the submit() method:

$('.editable').editable('submit')

the patched .save from https://github.com/werein/x-editable-rails/blob/master/vendor/assets/javascripts/editable/rails/editable_form.js.coffee is not called.

I'd try submitting a fix, but it's beyond my current skills :(

Support for Rails 5?

I would like to ask if do you plan to add support for rails 5 or if it is already working... I didn't find any reference to this topic in the documentation.
Thanks !

x-editable-rails gem throwing an error: undefined method `can?'

This error is thrown, when using the x-editable-rails:

ActionView::Template::Error (undefined method `can?' for #<#<Class:0x007f9012e30f68>:0x007f9012ee9e78>):
    14: 
    15:     .panel-body
    16:       /a.doc_title.editable id='doc_title_12345' data-name="doc[title]" data-title="Enter doc title" data-type="text" data-url='/docs/12345' href='#doc_title_12345' = doc.title
    17:       = editable doc, :title
    18: 
  app/views/docs/_single_doc_in_accordion.html.slim:17:in `_app_views_docs__single_doc_in_accordion_html_slim__2506304306156466629_70128411437560'
  app/views/docs/index.html.slim:52:in `_app_views_docs_index_html_slim___3263534966956214695_70128384677640'

Changed value doesn't get updated in database

Great looking gem.

I have added x-editable-rails to my application. I can get the editor pop-up and when I edit the value, it gets updated in my view, but value doesn't get updated in my table/database, so when I refresh my page, the old value is showing.

Here is what I have:
My application.js:

//= require global
//= require editable/bootstrap-editable
//= require editable/rails

My global.js:
$('.editable').editable();

My application.scss
@import "editable/bootstrap-editable";

class ApplicationController < ActionController::Base
  helper_method :xeditable?
  def xeditable? object = nil
    true
  end

My view:

- @campaign.posts.each do |post|
  .col-md-12.div-table.brd-rad-4
    %span.editable= editable post, :cpc

What I am doing wrong?

Thanks in advanced!

placeholder not working

=editable current_pack, :description , url: users_mod_pack_path(current_pack), placeholder: "Click to edit a description"

i would expect to read that text, instead it comes "Empty"

Adding validation when editing

Great gem ๐Ÿ‘

In my application I use client_side_validations gem for validating my form. Am I able to also use client_side_validations gem or other sort of validation to x-editable-rails?

I just want to validate, :price & :number & both of them can't be less the $0.010.

Currently in my Product model, I do:

class Product < ActiveRecord::Base
  validates :price, :number, numericality: {greater_than_or_equal_to: 0.010}

As I see it if I insert anything greater then 0.010, field gets updated, but if I for instance insert 0.0009, the field doesn't get updated (That's good), but no error is showing and the loading gear is just going around.

How can I show the error message when validation fails?

Any help is appreciated & thanks in advanced!

Problem with popover

Trying using xeditable with popover I have such issue

Uncaught Error: no such method 'show' for popover widget instance jquery.js?body=1:517
jQuery.extend.error jquery.js?body=1:517
(anonymous function) jquery.ui.widget.js?body=1:187
jQuery.extend.each jquery.js?body=1:658
jQuery.fn.jQuery.each jquery.js?body=1:267
$.fn.(anonymous function) jquery.ui.widget.js?body=1:179
Popup.call bootstrap-editable.js?body=1:1031
$.extend.innerShow bootstrap-editable.js?body=1:4735
Popup.show bootstrap-editable.js?body=1:1091
Editable.show bootstrap-editable.js?body=1:1803
Editable.toggle bootstrap-editable.js?body=1:1825
(anonymous function) bootstrap-editable.js?body=1:1548
proxy jquery.js?body=1:828
jQuery.event.dispatch jquery.js?body=1:5096
elemData.handle jquery.js?body=1:4767

Gemfile

gem 'jquery-rails', '~> 3.0.4'
gem 'bootstrap-sass', '~> 3.0.3.0'
gem 'font-awesome-rails', '~> 4.0.3.0'
gem 'jquery-fileupload-rails', '~> 0.4.1'
gem 'x-editable-rails', '~> 1.5.2', github: 'werein/x-editable-rails'

with rails turbolinks Uncaught RangeError: Maximum call stack size exceeded editable_form.js?body=1:12

rails 4.1.1
bootstrap 3.0.2
x-editable-rails 1.5.3

Uncaught RangeError: Maximum call stack size exceeded editable_form.js?body=1:12
(anonymous function) editable_form.js?body=1:12
EditableForm.saveWithUrlHook editable_form.js?body=1:47
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:48
EditableForm.saveWithUrlHook editable_form.js?body=1:4

undefined method `xeditable?' error shows up

I included this in _coment.html.erb

<%= editable [comment.article, comment], :content, url: edit_article_comment_path(comment.article, comment) %>

I also included a helper method below, which is included (helper_method :xeditable?) in the application controller. I don't use cancan authentication.

module ApplicationHelper

def xeditable?
  can?(:edit, object) ? true : false
end
  
  def can?(role, object)
     true 
  end
end

Assets break in sub URI deployments

When deploying to a sub URI, X::Editable::Rails is still looking for assets at /assets instead of /sub-uri/assets, breaking the images and glyphicons.

Edit: This is on Rails 4.0.2, and X::Editable::Rails 1.5.1

Gem is missing dependency on coffeescript

editable/rails is written in coffee script, but this gem does not have a dependency on coffee-rails. The only dependency listed is railties which does not have a coffee script dependency.

Feature request: better default parsing of Rails error responses

When returning Rails validation errors in the usual way:

format.json { render json: @obj.errors, status: :unprocessable_entity }

I get something like this:

screen shot 2013-12-02 at 10 00 47 pm

When I really want this:

screen shot 2013-12-02 at 10 01 10 pm

To get that, I've written a default error handler to massage the JSONified Rails validation errors:

$.fn.editable.defaults.error = 
  function(response, newValue) { 
    var field_name = $(this).data('name'),
        error_msgs = response.responseJSON[field_name];
    return error_msgs.join("; ");
  };

Should something like this be built into x-editable-rails?

UnCaught type error

Hey guys, love the gem.
everything seems to be working fine.
When I edit a field, the field is updated on the back end. which is great.
the popup or the inline edit field hangs there with the loading gif and doesn't disappear.
If i refresh the page the field is up dated properly.

These are the errors from my browser console

Uncaught TypeError: Cannot read property 'errors' of undefined error_handling.js?body=1:5
$.fn.editable.defaults.error error_handling.js?body=1:5
(anonymous function) bootstrap-editable.js?body=1:294
proxy jquery.js?body=1:828
fire jquery.js?body=1:3049
self.fireWith jquery.js?body=1:3161
done jquery.js?body=1:8238
callback

How do I make the loading gif disappear?

Thanks again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.