[Koha] Patron save button dissabled after adding JS to addbiblio

Eric Phetteplace ephetteplace at cca.edu
Sun Jun 14 08:44:05 NZST 2020


I suspect the error is in the condition on the very first line:

if ( $("#cat_addbiblio") )

This is always true so this runs on every page. The jQuery function returns
an object which evaluates to true. You want to look at the length property
instead (it will be 0 if there are no matching elements and 0 evaluates to
false). So

if ( $("#cat_addbiblio").length )

Best,
Eric Phetteplace
Systems Librarian
California College of the Arts

On Sat, Jun 13, 2020, 10:43 AM Alvaro Cornejo <cornejo.alvaro at gmail.com>
wrote:

> Hi
>
> I´m trying to make this JS work in 19.11.06, even though it is noted to
> work on 16.05.
>
> The JS was supposed to be enabled only on cataloging form, however, it
> locks/disables the save button in patron creations form. Any idea what's
> wrong with it?
>
> /
>
> https://wiki.koha-community.org/wiki/JQuery_Library#Check_validity_of_ISBN.2C_ISSN.2C_ISMN_and_URL_before_submitting_the_addbiblio_form
>
> This is the part of the JS that locks me down:
>
> if ( $("#cat_addbiblio") ) // only do this in the addbiblio form
> {
>   // add an additional event handler to the save buttons ( one already
> exists: .onOption() )
>   $("#saverecord, #saveandview, #saveanditems, #saveandcontinue").click(
> function( event ) {
>     var mes = "";
>     // run all tests as functions which might add a new error message to
> the existing ones
>     mes = test020a( mes );
>     mes = test022a( mes );
>     mes = test024a( mes );
>     mes = test856a( mes );
>
>     if (mes != "") {
>       alert(mes);
>       event.stopImmediatePropagation(); // block the other event handlers
> which trigger submission of the form
>       return false;
>     } else {
>       return true;
>     }
>   });
> };   // end if in addbiblio form
>
> Regards
>
> Alvaro
>
>
>
> |----------------------------------------------------------------------------------------|
>  Stay safe / Cuídate/  Reste sécurisé
> *7* Switch off as you go / Apaga lo que no usas /  Débranchez au fur et à
> mesure.
>  *q *Recycle always / Recicla siempre / Recyclez toujours
>  P Print only if absolutely necessary / Imprime solo si es necesario /
> Imprimez seulement si nécessaire
> _______________________________________________
>
> Koha mailing list  http://koha-community.org
> Koha at lists.katipo.co.nz
> Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
>


More information about the Koha mailing list