Giter Club home page Giter Club logo

best_in_place's People

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  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

best_in_place's Issues

Where has the best_in_place:setup generator gone?

The generator mentioned in the readme file (under "Installation") does not exist.
As far as I can see, there has been a lib/generators directory at one time (still there with the 0.2 tag, I believe) but in the current version it's missing.

My git / github skills are too limited to track down at what commit the directory and/or its included files have been removed. I can imagine it has been done for good reason, but in that case I think the documentation should be updated.

conflict with $(window).bind('popstate')

Hey,
In my project, I have some code like below to make AJAX history works

jQuery ->
  if history and history.pushState
    $('a[data-remote]').live 'click', ->
      history.pushState null, '', this.href

    $(window).bind 'popstate', ->
      $.getScript location.href

  $('.best_in_place').best_in_place()

in this case, the best_in_place didn't work except I remove $(window).bind('popstate'), seems like they're conflict, could you take a look?

Thanks

"-" not shown on empty fields

First, great gem!
I found a minor issue on doing an in-place-edit. If I remove the content of the element completely, the "-" is not shown and therefore, the element is not clickable any more (as there is nothing to click). However, after a page reload it is visible. Version used 0.1.9.

Maintain html attributes

Maintain all attributes that may be set as $(form_field).attr(name, value), example maxlength.

nested attributes

Hey it is possible use that with nested attributes, I try:

best_in_place @profile.user, :name

and

best_in_place @profile, "user_attributes[name]"

But have no success

line breaks in textareas

This is a feature request.

When using a textarea, the developer often intends for the field to contain line breaks. Best_in_place doesn't display newlines in textareas as html <br> tags. It would be really convenient if it did by default, or had an option to.

I was able to implement a workaround with a display_as, but there are two problems with it:

  1. During the time between sending the ajax request and receiving the response, it temporarily is displayed without the breaks, and then switches over. This is a little ugly.
  2. It's a rather complicated workaround for a really common task.

Let me know if this is already possible and I just missed it.

is :nil available for select fields?

Lets say I have:
<%= best_in_place @case, :priority, :type => :select, :collection => @Priorities %>

and the "priority" is currently null in the database. I want to show something in the view for the user to click on so they can set the priority.

Is this possible?

Hidden param

Hello Bernat,

First of all I would like to say Great Job! And continue...

For my reason I need to send object's id, like hidden param, with edited attribute.

I.e if change user's name, then controller should receive "user"=>{"id"=>"real_user_id", "name"=>"new_name"} params.

How can I do that?

S

Change updated object in several places

Hello
I use best_in_place in dialog window over the page that contains same objects, that I'm updating in dialog.
I.e. I have page:

......
<div id="project_groups_index">
<% @project_groups.each do |group| %>
    <p id="<%= "project_group_link_container_#{group.id}" %>"><%= link_to group.name, "#{projects_path}?scope=#{group.id}" %></p>
<% end %>
 </div>
  <input type="button" value="<%= t('project_group.manage') %>" id="project_groups_dialog_link" />
  <div id="project_groups_dialog" style="display:none"><%= render 'project_groups/list' %></div>
.......

I have _list:

 <div id="project_groups">
<%= render @project_groups %>
 </div>
 </br>
   <p><%= t "project_group.new_project_group" %></p>
    <%= semantic_form_for current_account.project_groups.new, :validate => true, :remote => true do |f| %>
     <%= render 'project_groups/form', :f => f %>
  <% end %>

And I have _project_group:

 <p id="<%= "project_group_#{project_group.id}" %>">
 <%= best_in_place project_group, :name, :type => :input, :path => update_inline_project_group_path(project_group) %> 
 <% if project_group.projects.all.empty? %>
  <%= link_to t('share.destroy'), project_group, "data-confirm" => t('share.are_you_sure'), "data-method" => :delete, :remote => true, :disable_with => '<img src="/assets/spinner.gif"/>' %>
   <% end %>
  </p>

So I want to change project groups names on page after user update it in dialog. Is it possible?

Tooltip for editable text

It would be useful if we have tooltip displays when a user move mouse over the editable text because some times we don't want to use label to tell which field of this text.

problem when controller is inside namespace

I've been trying to implement best_in_place on my app for 2 weeks now but couldn't find a solution so I'm posting here. Anyway, I have the following code on view

<%= best_in_place [:admin, smiley], :tags %>

But I kept getting this error:

NoMethodError in Admin/smileys#index

Showing /Users/myuser/workspace/rails/myapp/app/views/admin/smileys/index.html.erb where line #32 raised:

undefined method `tags' for #Array:0x00000104fc4298

When using simple code:

<%= smiley.tags %>

It prints correct data so I think this is not a case where smiley object doesn't exit.

Anyway I have my controller inside a namespace. Here's the definition

class Admin::SmileysController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
layout "admin"
...

The controller was generated by rails scaffold command although i made some modification but shouldn't affect how best_in_place works.

I'm also using the following things:

Ruby: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
Rails: 3.1.3
Rake: rake 0.9.2.2

Cannot read property 'activateForm' of undefined

This is my code:

<%= best_in_place ticket, :target, :type => :date, :display_with => :format_date, :helper_options => {:use_time => :false, :short => :true} %>

Regular text field works fine as well as dropdown select fields but :type => :date I get this error in my inspector:

Uncaught TypeError: Cannot read property 'activateForm' of undefined    best_in_place.js:129

Is there something else I should be doing? Thanks so much!

Cannot read property 'activateForm' of undefined... still.

I have multiple instances of <%= best_in_place ticket, :target, :type => :date %> on a single page but I'm getting this error:

application.js:25 Uncaught TypeError: Cannot read property 'activateForm' of undefined

I've looked at this: #70

And I am updated to the most recent version of the gem. Any other help would be great! Thanks!

Use 'model_name' method to get class name

Currently you have in helper.rb:

data-object='#{object.class.to_s.gsub("::", "_").underscore}'

While it's not possible to override class for the object, ActiveRecord and ActiveResource have a model_name method which gives an opportunity to override how the object will be named in forms. Consider using this method when it's possible please, like:

name = object.class.respond_to?(:model_name) ?
  object.class.model_name : object.class.name.gsub("::", "_").underscore

Crash on moving spawn point

Log:

1/1/2012 5:12 PM: Error - Object reference not set to an instance of an object.
at TEditXna.Editor.Tools.SpriteTool.MouseDown(TileMouseState e) in D:\Dev_PROJECTS\Terraria\Terraria-Map-Editor\TEditXna\Editor\Tools\SpriteTool.cs:line 31
at TEditXna.ViewModel.WorldViewModel.MouseDownTile(TileMouseState e) in D:\Dev_PROJECTS\Terraria\Terraria-Map-Editor\TEditXna\ViewModel\WorldViewModel.cs:line 253
at TEditXna.View.WorldRenderXna.xnaViewport_HwndLButtonDown(Object sender, HwndMouseEventArgs e) in D:\Dev_PROJECTS\Terraria\Terraria-Map-Editor\TEditXna\View\WorldRenderXna.xaml.cs:line 606
at BCCL.UI.Xaml.XnaContentHost.GraphicsDeviceControl.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in D:\Dev_PROJECTS\BCCL\BCCL.Xna\UI\Xaml\XnaContentHost\GraphicsDeviceControl.cs:line 443
at System.Windows.Interop.HwndHost.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at TEditXna.App.Main() in D:\Dev_PROJECTS\Terraria\Terraria-Map-Editor\TEditXna\obj\x86\Release\App.g.cs:line 0

A resource called "searches" breaks this

I don't know if anyone else has had this issue.

I tried for a good while to figure out what I had done wrong in setting this up. For some reason, it just turned out that if your model is called "search" the field can only be updated once, and does not display your changes. Tried all the input types, and everything, but ended up just renaming my resource to "lookups" and that seemed to do it. I'm not sure if this is a reserved word somewhere or what was happening.

I looked for a workaround, but nothing was forthcoming.

Automatic detection of :type

Make optional the use of a :type argument since we can discover it by inspecting the AR fields, like simple_form does.

Collection select with nil value

This issue was raised previously (#6), but there was no answer, at least none that fixed my problem. I am using bip with decorators (draper), so where you see model, that is the correct syntax. When I tried
best_in_place(model, :hospital_id, type: :selection, collection: Hospital.all.collect {|h| [h.id, h.name]}, nil: 'Click to add a hospital')
that did not seem to work. I then tried
best_in_place(model, :hospital_id, type: :selection, collection: ['', "Click to add a hospital"] + Hospital.all.collect {|h| [h.id, h.name]})
which also did not work. When a user has a nil hospital_id, instead of displaying the "click to add hospital", it displays nothing, and is not clickable.

Error when field has no value

When a field has no value, and the text from the :nil parameter is being shown, if there is an error, the text is not shown again which let the user without the chance to write something new.

:html_attrs

hey, any advice on how to use this? I'm trying to increase the length of the input field, but can't seem to get the format right for parsing the option.

Formatting an editable number field?

I'm using best_in_place to make a price field editable. I used number_to_currency to display the price.
I wonder how I can still use that with best_in_place? Or at least format the price display to a nice xx.xx format.
Any suggestions?

Additional Callback Function

Would be nice to be able to specify an additional callback function. This could be used to update other UI elements on the page which might be useful for feedback.

Was able to emulate this functionality by adding my desired js to the best_in_place.js callback functions, but that's kinda messy.

I feel like the current respond_with_bip to be somewhat limiting.

Readme question

Is it worth mentioning in the readme what the update action might look like as far as a respond_to block with format.json?

Caused some confusion for me.

Integration with jquery-ui date picker

bernat - excellent work here, this is so much cleaner than other similar plugins! I have just implemented in place of super_inplace_controls when I moved to rails3.

I use jquery-ui datepicker (http://jqueryui.com/demos/datepicker/) in my application un-obtrusively so I just set :class => 'datepicker' on any text field and it will render the calendar.

Can you think of a way that I can integrate these two, my thoughts were either:
a. Set a html class on the best_in_place field to pass through to the text field that is rendered
b. Try and create a :type => :date option to call the date picker.

Your advise and assistance would be greatly appreciated.

Can't seem to make test_app work - Extra close paren, best_in_place.js Ln 72

Hi,

I'm trying to use your gem, but I can't seem to get working on my app, nor your test app.

I clone the repo, go into test app, and run

bundle install
rake db:migrate
rake db:seed

then go to 127.0.0.1:3000, click on a user name, then try to click on one of the editable fields. However, nothing happens (it doesn't change into a form), and i'm getting a javascript error in firebug:

jQuery(".best_in_place").best_in_place is not a function
(?)()applic...1459353 (line 6)
noConflict()jquery...1459353 (line 29)
j = function()
inArray()jquery...1459353 (line 37)
[Break On This Error] jQuery(".best_in_place").best_in_place();

... umm.. nevermind, just realized...

I think you have an extra parenthesis at the end of line 72 in best_in_place.js that's breaking things

Display_as always reverts textarea to original content

I would like to use best_in_place with a textarea type of field, and format the textarea to display new lines. I have the following code in my view:

<%= best_in_place goal, :notes, :type => :textarea, :display_as => :display_notes %>

And the code for the display_notes method:

def display_notes
    h.simple_format model.notes
end

I'm using respond_with_bip in my controller's action.

The text is displayed correctly, and updates correctly the first time, but when I click to edit it again, the textarea reverts back to the original text and does not display the new value. So you basically can't append text, and you also lose you previous changes, because as soon as you click away, best_in_place updates the model attribute again.

I have noticed that there is an html attribute called "data-original-content" which always stays the same, and doesn't updates when I edit the textarea, even the first time, when the change is successful. The "data-original-content" appears only when you use the :display_as option. If I don't use it, then everything works fine, but I obviously I will lose my textarea formatting.

Does anyone know a workaround for this problem?

Steps to reproduce:

  1. Click on field which has some text (e.g. "foo")
  2. Text area has "foo". Enter "bar"
  3. Click somewhere else - the field is updated, now displays "foo bar", and "data-original-content=foo".
  4. Click on field again. Text area displays "foo".

:nil always gets displayed if :display_as is used

I'm doing something kind of like:

<%= best_in_place current_user,
                                    :bio_markup,
                                    :display_as => :bio
                                    :type => :textarea,
                                    :ok_button => "Save",
                                    :path => update_bio_path,
                                    :nil => "Some block of text to display if nil"

%>

Initially everything is great, it displays "Some block of text to display if nil". The user clicks that, edits it to "This is edited text", hits enter.. everything is perfect. Refresh the page, now they see "Some block of text to display if nil" and "This is edited text".

It's displaying the text for :nil when it shouldn't. Inspecting the User object, there is text saved on both the bio and bio_markup fields (as there should be).

Direct support to bind display_as with a view helper method

Usually we want to use display_as together with another view helper such as number_to_currency or simple_format. To do this now we need to include an actionview helper into our model class. I think we should provide an easy integration option.

display_as fails after edit

I can use display_as to format a currency field, but that formatting is lost after the field is edited for the first time. After that it just reverts to a plain number. I have no idea how to debug or solve this so I'm afraid I'll just have to leave this info here. On a brighter note, excellent work with BIP. It's made in place editing far more accessible for me. Many thanks

HTML5 contenteditable attr

Would you accept a pull request with "contenteditable" attr. added to the html tag generated by best_in_place helper?

Thanks

Editing nested resources?

Awesome gem guys. I'm new to Rails and having some trouble with syntax for a nested resource. First, is it possible to use them? My routes looks like this:

resources :users do
   resources :goals
end

and using in a view either of

<%= best_in_place [@user, @goal], :description %>
<%= best_in_place @goal, :description %>
have NoMethodErrors ( undefined method 'description' and undefined method 'goal_path' respectively)

Am I doing something wrong with the syntax or is this just not possible with the gem?

":display_with => :simple_format" causes error

As reported by brianmaissy in issue #62 , using
best_in_place user, :notes, :type => :textarea, :display_with => :simple_format
causes the following error
undefined method 'white_list_sanitizer' for Module:Class

Not working for remote form submit

i have a form on index page i submit it using remote data is updated whereas best in place editing doesn't work
$("#myTable tr:last").after('<%= escape_javascript(render(@comment)) %>');
In this comment gets added and it is uneditable.
Please help with this;

1 or 0 instead of true or false

Is there a way to configure best in place to use 1 or 0 instead of true or false when using :checkbox type. Currently, we have a system that uses 1 or 0.

Thanks
Rey

Missing template for haml

Hello, after that commit 0027053, application with haml templates does not working, when open any page, we get an exception:

ActionView::MissingTemplate (Missing template users/index, application/index with {:handlers=>[:coffee, :builder, :erb], :formats=>[:html], :locale=>[:en, :en]}. Searched in:

  • "/home/finist/Projects/best_in_place_haml_problem/app/views"
    ):

I created a test application where you can see it: https://github.com/finist/best_in_place_haml_problem

Fields not being rendered

I have implemented best_in_place and have it working in several pages of my application. On one of my views (cases/show) I am using several best_in_place's but none of them are rendering anything (i.e. no hover action)

I know I have the gem and javascript includes right.

I am calling as follows:
<%= best_in_place @case, :case_status_id, :type => :select, :collection => @statuses.map { |e| [e.name, e.id] } %>

When I 'view source' of the offending page I can see this:

This all looks right to me.

I have tried in different browsers (FF Beta 4, and Safari 4) but no dice.

Are there requirements in the model or controller that I am missing?

What's :html_attrs supports?

I'm trying to use this parameter like: best_in_place income, :description, :html_attrs => { :size => 5 } and this isn't working.

When I change from size to maxlength this works fine. But, why :html_attrs doesn't support size option?

IDs not unique

If best_in_place is used in a partial, the generated HTML spans all have the same id and so one ends up with multiple similar ids on one page which is invalid. Could you please add an option to set the id manually, e.g. using dom_id?

Please update :html_args to :html_attrs in README.md

I think :html_args is a typo as it has no effect on the output HTML code. Looking at lib/best_in_place/helper.rb, it's clear that it should be :html_attrs.

Also, please add inner_class to the list of options in the README.md as it's quite useful.

I can't use :type => :date

When I use this combination best_in_place income, :date_of_credit, :type => :date and refresh my page, Firebug show me this error message:

BestInPlaceEditor.forms[this.formType] is undefined
this.activateForm = BestInPlaceEditor.forms[this.formType].activateForm;

I'm following the README example.

Thanks!

Sanitize still allows for inject attack

You can HTML encode opening and closing HTML tags and sanitize will encode them, resulting in executable script tags.

For example, enter this into a text field and when you submit the value, it executes the script:

&lt;script&gt;alert('hi');&lt;/script&gt;

Update Multiple Fields

Was wondering if you have any plans to support multiple fields update.

as in for example

i have a field called unit_price
and a field called quantity
and another field called total

displayed in a row.

I want it to be such that if I update the quantity and on the server side i have a call back function that updates the total when we re display the data it actually updates the 'total' display field as well?

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.