Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:18:01+00:00 2026-05-22T03:18:01+00:00

trying to create a form inside a modal dialog. But i would like this

  • 0

trying to create a form inside a modal dialog. But i would like this form to contain datepickers and other widgets from jquery.

At the moment I’m doing this:

In the view:

<p><%= link_to "New Event", new_event_path, :remote => true%></p>

In application.js

jQuery(function($) { 

    $('a[data-remote]').live('ajax:beforeSend', function(e, xhr, settings){
        xhr.setRequestHeader('accept', '*/*;q=0.5, text/html, ' + settings.accepts.html);
      });

    $('a[data-remote]').live('ajax:success', function(event, data, status, xhr){
    $('#modal').html(data);
    $('#modal').dialog({ 
    show: "slide",
    hide: "slide",
    draggable: true,
    modal: true });
    });
    });

If in my partial at the top of the page I put

<script>$(function (){  
    $('#event_date').datepicker();  
});
</script>

Then when the modal dialog shows up, my date field will appear with datepicker, but I would ideally want to put this code inside application.js, rather than in the view.

I’m new to jquery, which is maybe why i’m finding this difficult to do. any suggestions are welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:18:02+00:00Added an answer on May 22, 2026 at 3:18 am

    put the datepicker initializing in the open callback of the dialog!

    $('a[data-remote]').live('ajax:beforeSend', function(e, xhr, settings){
        xhr.setRequestHeader('accept', '*/*;q=0.5, text/html, ' + settings.accepts.html);
    });
    
    $('a[data-remote]').live('ajax:success', function(event, data, status, xhr){
        $('#modal').html(data);
        $('#modal').dialog({ 
            show: "slide",
            hide: "slide",
            draggable: true,
            modal: true,
            open: function(event, ui){
                $('#event_date').datepicker(); 
    
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a form with white label inside, that when I click
I am trying to create a usercontrol that is an extremely simple form. This
I am trying to create a dialog pop-up box with 2 forms inside of
I'm trying to create a form that has an expandable widget. The problem is
I am trying to create a form in Rails 2.2.2 that populates a field
Trying to create a user account in a test. But getting a Object reference
Trying to create my first iPhone app that would play back audio. When I
I'm trying to build modal windows on the fly from single javascript object passed
I'm creating an AJAX form. The problem is when I'm trying to create a
I'm sure this is a completely obvious beginner question, but trying to find answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.