Skip to content

Javascript error in all pages #14

@linuxonrails

Description

@linuxonrails

I'm submitting a ..

  • Bug Report
  • Feature Request

Current behavior:

application-61842a409a92dcf0d733c8906204ef9b9e413de29ca569171225c7a3c28fe5d4.js:63218 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at word_count (application-61842a409a92dcf0d733c8906204ef9b9e413de29ca569171225c7a3c28fe5d4.js:63218:45)
    at updateEventTypeRequirements (application-61842a409a92dcf0d733c8906204ef9b9e413de29ca569171225c7a3c28fe5d4.js:63239:9)
    at HTMLDocument.<anonymous> (application-61842a409a92dcf0d733c8906204ef9b9e413de29ca569171225c7a3c28fe5d4.js:63242:5)
    at mightThrow (application-61842a409a92dcf0d733c8906204ef9b9e413de29ca569171225c7a3c28fe5d4.js:3557:29)
    at process

Expected correct behavior:

No javascript errors in console.

Steps to reproduce:

Visit any page without a tag with event_abstract id attribute.

Other information:

The problem is in app/assets/javascripts/osem.js:

function word_count(text, divId, maxcount) {
    var area = document.getElementById(text.id)

    Countable.once(area, function(counter) {
        $('#' + divId).text(counter.words);
        if (counter.words > maxcount)
            $('#' + divId).css('color', 'red');
        else
            $('#' + divId).css('color', 'black');
    });
};

/* Wait for the DOM to be ready before attaching events to the elements */
$( document ).ready(function() {
    /* Set the minimum and maximum proposal abstract word length */
    function updateEventTypeRequirements() {
        var $selected = $("#event_event_type_id option:selected")
        var max = $selected.data("max-words");
        var min = $selected.data("min-words");

        $("#abstract-maximum-word-count").text(max);
        $("#abstract-minimum-word-count").text(min);
        word_count($('#event_abstract').get(0), 'abstract-count', max);

$('#event_abstract') return an empty jQuery object en (almost) all pages. $('#event_abstract').get(0) returns undefined.

word_count($('#event_abstract').get(0), 'abstract-count', max); => text is undefined. text.id throws an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions