PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

RJS error in ActiveScaffold Sortable #743

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have installed the plugin and everything works except for one RJS errors I 
get in 
Safari/Firefox/Chrome whenever creating a new object inside a nested table, or 
deleting/updating an existing object.

In Safari, the first error reads: "TypeError: Result of expression 'count' 
[undefined] is not an 
object." A second alert outputs a long string of HTML code.

I'm using Rails 2.3.5 and the latest version of Active Scaffold.

Does anyone know what may be causing this?

Thanks,

Christian

Original issue reported on code.google.com by christia...@gmail.com on 11 Apr 2010 at 3:23

GoogleCodeExporter commented 9 years ago
Please, post your controller

Original comment by sergio.c...@gmail.com on 12 Apr 2010 at 7:36

GoogleCodeExporter commented 9 years ago
Please, post your controller

Original comment by sergio.c...@gmail.com on 12 Apr 2010 at 7:54

GoogleCodeExporter commented 9 years ago
My source code is below. Correction: I'm still seeing two separate error 
messages after updating a record. 
Thanks.

--
class ItemsController < ActionController::Base
  include AuthenticatedSystem # for restful authentication
  before_filter :login_required
  layout "activescaffold"

  active_scaffold :items do |config|
    config.list.columns << :active_views
    config.nested.add_link("Object images", [:images])
    config.columns = ['title', 'category', 'country', 'year', 'dimensions', 'price', 'description', 'url', 'images', 'home', 
'collection', 'archive']
    config.list.columns = ['title', 'category', 'price', 'url', 'home', 'collection', 'archive']
    config.columns[:url].label = "Thumbnail"
    config.columns[:home].inplace_edit = true
    config.columns[:collection].inplace_edit = true
    config.columns[:archive].inplace_edit = true
    config.actions.exclude :show
  end
end
--

Original comment by christia...@gmail.com on 12 Apr 2010 at 1:13

GoogleCodeExporter commented 9 years ago
Do you get the error when you create a record on items controller? Or do you 
get the
JS error when you create a record on images nested scaffold? In that case, post 
your
images controller code.

Original comment by sergio.c...@gmail.com on 12 Apr 2010 at 2:34

GoogleCodeExporter commented 9 years ago
Yes, it happens in the nested scaffold. Below is my images controller code. 
Removing the 2 lines of "sortable" 
code prevents the error from occurring, leading me to think that the culprit 
must be the plugin...

--
class ImagesController < ActionController::Base
  include AuthenticatedSystem # for restful authentication
  before_filter :login_required

  layout "activescaffold"
  active_scaffold :images do |config|
    config.actions << :sortable
    config.sortable.column = :position
  end

  def item
    @images = Image.find(:all)
  end
end
--

Thanks!

Original comment by christia...@gmail.com on 13 Apr 2010 at 12:10

GoogleCodeExporter commented 9 years ago
I'm attaching screenshots of the error messages I'm getting, in case it helps...

Original comment by christia...@gmail.com on 13 Apr 2010 at 12:11

Attachments:

GoogleCodeExporter commented 9 years ago
Are you using an updated copy of
http://github.com/activescaffold/active_scaffold_sortable?

Original comment by sergio.c...@gmail.com on 13 Apr 2010 at 7:34

GoogleCodeExporter commented 9 years ago
Also, try to copy frontends/default/javascripts/active_scaffold.js to
public/javascripts/active_scaffold/default/active_scaffold.js, maybe that file
wasn't updated when you update the plugin.

Original comment by sergio.c...@gmail.com on 13 Apr 2010 at 7:39

GoogleCodeExporter commented 9 years ago
I installed the latest version of active_scaffold_sortable, and also copied 
active_scaffold.js from the 
active_scaffold plugin directory to public, but I'm still seeing the error.

Was there intended to be an override of active_scaffold.js in the 
active_scaffold_sortable plugin directory? If so, I 
couldn't find it...

Thanks.

Original comment by christia...@gmail.com on 13 Apr 2010 at 10:32

GoogleCodeExporter commented 9 years ago
No, there is no override of active_scaffold.js

Can you debug with firebug? Under script menu, check "stop on all errors", and 
tell
me line with the error. Or add a breakpoint in line 78.

You can use Safari debugger but I can't give instructions to you.

Original comment by sergio.c...@gmail.com on 14 Apr 2010 at 7:24

GoogleCodeExporter commented 9 years ago
The line with the error appears to be 77: "count.innerHTML = 
parseInt(count.innerHTML) + 1;"

Original comment by christia...@gmail.com on 15 Apr 2010 at 3:12

GoogleCodeExporter commented 9 years ago
On deletion, line 72 throws the error: "count.innerHTML = 
parseInt(count.innerHTML) - 1;"

Original comment by christia...@gmail.com on 15 Apr 2010 at 3:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
That is not last version:
master ->
http://github.com/activescaffold/active_scaffold/blob/master/frontends/default/j
avas
rails-2.3 ->
http://github.com/activescaffold/active_scaffold/blob/rails-2.3/frontends/defaul
t/ja

Original comment by sergio.c...@gmail.com on 15 Apr 2010 at 7:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I updated the version, and it no longer throws the above errors. However, I do 
still get an error when creating a 
new item inside a nested table (though no longer on deletion). I'm attaching 
new screenshots of the error, and 
can set a breakpoint if that helps. Thanks!

Original comment by christia...@gmail.com on 15 Apr 2010 at 12:03

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, I can't reproduce that bug. Please add a breakpoint to find the line of 
the
error. Have you override on_create.js.rjs on your controller?

Anyway, I have fixed a bug in active_scaffold_sortable, instead of moving to 
bottom
the new row it was inserting the row id as text.

Original comment by sergio.c...@gmail.com on 16 Apr 2010 at 10:50

GoogleCodeExporter commented 9 years ago
Your last update fixed the bug! Thanks so much, appreciate your help with this. 
Now everything is working 
fine...

Thanks,

Christian

Original comment by christia...@gmail.com on 16 Apr 2010 at 12:02