开发者

"Create Another XXX" button not working in ActiveScaffold

Update#1 Surprisingly if in Firebug, I change the generated <input> HTML to <a>, it works as expected. But to make this workaround permanent, I will have to change ActiveScaffold's code.

Update#2 For now I have changed the code of ActiveScaffold. This solves my problem. But the questions is still not 开发者_如何转开发answered.

I have a model ListingMovie:

class ListingMovie
  has_many :movie_shows, :dependent => :destroy
  belongs_to :movie
  ...
  ...
end

and MovieShow:

class MovieShow
  belongs_to :listing_movie

  validates_presence_of :start_time, :end_time
end

I have Manage::ListingMoviesController:

class Manage::ListingMoviesController < Manage::BaseController
  helper Mange::MovieShowsHelper

  active_scaffold :listing_movie do |config|

    config.columns = [:movie, :listing, :start_date, :end_date, :movie_shows]
    config.columns[:listing].form_ui = :select
    config.columns[:movie].form_ui = :select
  end

  protected

  def self.active_scaffold_controller_for(klass)
    return Manage::MoviesController if klass == Movie
    return Mange::MovieShowsController if klass == MovieShow
  end
end

and Manage::MovieShowsController

class Manage::MovieShowsController < Manage::BaseController
  active_scaffold :movie_show do |config|
    config.subform.columns = [:start_time, :end_time]
  end
end

When I try to create/update a ListingMovie, I am shown a form that has a "Create Another Movie Show" the end. Earlier when I clicked it, it made an Ajax request and added two new fields at the bottom of the form that let me specify start_time and end_time for associated MovieShow. Now When I click on it, no request is made to the server. And hence new fields are not added to the form.

Following is the HTML of the button:

<input data-remote="true" href="/manage/listing_movies/edit_associated?association=movie_shows" id="as_manage__listing_movies--movie_shows-subform-create-another" style="" type="button" value="Create Another Movie show">

I am unable to debug this as I can see any errors. Clicking the button simply does nothing.

One thing to notice is that if I put some erroneous data in the form and then try to "Create/Update" a ListingMovie, the form is rendered again with a "new" form fields to specify start_time and end_time.

I am using Rails 3.0.1 and ActiveScaffold 3.0.6 Thanks!


You cannot use href in a input tag. Define an onclick event for the button or use it inside an ancor tag

<a href="/manage/listing_movies/edit_associated?association=movie_shows">
<input data-remote="true" id="as_manage__listing_movies--movie_shows-subform-create-another" style="" type="button" value="Create Another Movie show">
</a>

this may be helpful to you

http://htmlhelp.com/reference/html40/forms/button.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜