tags:

views:

52

answers:

2

hi friends

in the lightbox i render form containing textbox and buttons(next and prev)

problem is, after i edit content in textbox and click "Enter button" it should fire click event on "next" button so that it takes to next form in lightbox

i used following code, but it is refreshing entire page instead of focusing "next" button alone.

And it gives error: ActionController::MethodNotAllowed Only get requests are allowed

$("input").bind('keyup', function(event){ if(event.keyCode == 13){ $("#nextbtn").click(); } });

please correct if any thing wrong with the syntax

+3  A: 

You need to return false and call preventDefault on the event object in order to prevent submission of the form.

$( 'input' ).bind( 'keyup', function( e ) { 
    if( e.keyCode == 13 ) { 
       $( '#nextbtn' ).click(); 
    }
    e.preventDefault();
    return false;

} );

Also, change your method attribute to GET, the error is stating that you cannot submit POST requests.

Jacob Relkin
page is still loading with this code..so it take to error: ActionController::MethodNotAllowed Only get requests are allowedAnything else can be done..
lamrin
A: 

You may also need to invoke the page as an Iframe from the Lightbox so it doesn't close automatically once the form is submitted.

Most lightbox plugins for Jquery give a parameter to launch it as an iframe.

niggles