Google Groups

Re: [omeka-dev] Re: jQuery in config form


John Flatness Apr 3, 2012 1:58 PM
Posted in group: Omeka Dev
A script should run just fine, even when included inside a form.

What exactly do you want it to do? What I see there *should* throw up an
alert if the user has typed a space in the secret key field. I would
bind to the "submit" event on the form instead of "click" on the button,
and you probably want to return false or preventDefault() if you catch a
validation error.

As for jQuery referencing the "Add Item" or "Save Changes" button, you
should be able to add a script to that page either through the
'admin_items_form_tabs' filter or just through the 'admin_theme_header'
hook, then refer to the button by ID or name.

On 04/03/2012 02:42 PM, Daniel wrote:
> On a similar note, is there a hook in which jQuery can reference the
> "Add Item" or "Save Changes" button in when adding or editing an item?
>
> On Apr 2, 11:25 pm, Daniel<dvizz...@gmail.com>  wrote:
>> I'm trying to do some basic form verification in my config_form.php
>> file with jQuery:
>>
>> function config_form_hook_name()
>> {
>>          include 'config_form.php';
>>
>> }
>>
>> And then, in confif_form.php:
>>
>> <div class="field">
>>
>>          <div class="inputs">
>>                  //some inputs
>>          </div>
>> </div>
>>
>> <script type="text/javascript">
>>      jQuery(document).ready(function() {
>>
>>              jQuery('input[name=install_plugin]').click(function(event) {
>>                  if
>> (jQuery('input[name=AWSAccessKeyId]').val().indexOf(" ") != -1){
>>                                  alert('Please enter valid secret key.');
>>                  }
>>                  //etc...
>>              });
>>      });
>> </script>
>>
>> This does not work. I think it might be because the javascript is
>> nestled in a form. Any thoughts?
>