Jörn,

I got it. Thank you for your direction!!!!!


Zhiyin




On Tue, Aug 18, 2009 at 1:15 PM, Zhiyin Pan <[email protected]> wrote:

> Jörn,
>
> thanks for the reply. I really appreciate it.
> do you have a simple example that i can look at?
>
>
> Zhiyin
>
>
>
>
> On Tue, Aug 18, 2009 at 11:09 AM, Jörn Zaefferer <
> [email protected]> wrote:
>
>>
>> Sounds like you have a form that simply gets submitted when you press
>> enter. Instead of trying to capture the keypress event, you could bind
>> a submit event to the form. Preventing the submit will then work for
>> both clicking on the submit button as well as pressing enter within
>> any of the inputs.
>>
>> Jörn
>>
>> 2009/8/18 zhiyin <[email protected]>:
>> >
>> > Hello, my fellow jquery UI developers,
>> >
>> > I am having trouble with binding 'keypress' event to an input field
>> > for a form in a jquery ui dialog.
>> > It seemed that when I type 'enter' in an input field, the whole page
>> > is refreshed (which means the dialog disappeared completely).
>> >
>> > Can somebody shed some light on this one?
>> >
>> > thx in advance,
>> >
>> >
>> >
>> > requestContactForm = function()
>> > {
>> >    $.ajax({
>> >        type: "POST",
>> >        url: "ajax/profile.ajax.php",
>> >        data: dataString,
>> >        success: function(data){
>> >            $dialog = $("#dialog");
>> >            $dialog.html(data).dialog({
>> >                title: '编辑联系方式',
>> >                bgiframe: true,
>> >                open: onEnterSubmitContactForm, // this is where i
>> > register the event.
>> >                modal: true,
>> >                height: 400,
>> >                width: 500,
>> >                buttons: {
>> >                    'Submit': function(){
>> >                        d6w.fl.fn.submitContactForm(formType, id);
>> >                    },
>> >                    'Cancel': function(){
>> >                        $(this).dialog('destroy');
>> >                        $("#dialog").html('');
>> >                    }
>> >                }
>> >            }).show();
>> >        }
>> >    });
>> > };
>> >
>> >
>> >
>> > onEnterSubmitContactForm = function(){
>> >    alert("i need to be here.");
>> >    $('input').keypress(function(e){
>> >        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode ==
>> > 13)) {
>> >            submitContactForm(formType, id);
>> >        }
>> >
>> >        return false;
>> >    });
>> > };
>> >
>> >
>> > >
>> >
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to