jQuery in config form

21 views
Skip to first unread message

Daniel

unread,
Apr 3, 2012, 2:25:56 AM4/3/12
to Omeka Dev
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?

Daniel

unread,
Apr 3, 2012, 2:42:02 PM4/3/12
to Omeka Dev
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?

John Flatness

unread,
Apr 3, 2012, 4:58:03 PM4/3/12
to omek...@googlegroups.com
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.

Daniel Vizzini

unread,
Apr 3, 2012, 6:51:54 PM4/3/12
to omek...@googlegroups.com
John,

I quickly used the bind function and it still did not work, no doubt for what will be an embarrassingly obvious reason.

In the meantime I got my code up on github. It implements a multi-threaded curl object to get Omeka objects to the Internet Archive's S3-like service, and it works (although it certainly needs some work).

In what I am sure are your copious quantities of free time, feel free to hack:


I'll get it through the official Omeka plugin channels soon.

-Daniel Vizzini

--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To post to this group, send email to omek...@googlegroups.com.
To unsubscribe from this group, send email to omeka-dev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/omeka-dev?hl=en.


Reply all
Reply to author
Forward
0 new messages