Rails and modal jquery dialog form

后端 未结 2 1381
轻奢々
轻奢々 2020-12-24 03:43

I\'m new to using jquery modal dialog boxes with rails and was wondering how I can :

  1. show a jquery modal dialog box with 1 field (eg \"title\")
  2. post t
2条回答
  •  有刺的猬
    2020-12-24 04:04

    For modal box I use jQuery Tools.

    Once you set that up, next step is to bind an ajax request when the form is submitted (eg: form.submit(function(){ $.post... })) and post the form's data to controller.

    Third step is setting up your Rails controller to respond to ajax request (using respond_to block) and render something as response (probably using :layout => false).

    If validation failed, you will replace content of your modal box with this response body, or if successful (let's say response was just head :ok), you will display a success message.

    I hope this makes sense to you.

提交回复
热议问题