Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash doesn't seem correctly configured, can't submit with errors #51

Open
terryaney opened this issue Jan 15, 2021 · 3 comments
Open

Comments

@terryaney
Copy link

I select an Instructor, go to the Edit page and clear everything out and hit save.

I then get a script error what _.reject() is not a function in showSummary().

I looked at your normal Contoso repo (I didn't pull/test) and noticed that the lodash folder has many more files in it instead of only core.js. I didn't see a libman.json to try and update the libraries, so not sure if I'm missing something and didn't build correctly (just hit F5 and it worked) or if there is a problem with the script.

Additionally, if I instead of clearing all inputs and submitting, I just append the letter 'a' to the date hire and submit. It submits successfully, redirects to listing page, but did not display error nor save bad data.

Side question when you look at this. Trying to understand where the ajax call submits to when clicking submit on Edit page. The form.action is undefined and I put break points in all the methods in CreateEdit.cshtml.cs and never hit any of them.

@RickTheHat
Copy link

Some packages got updated and I'm sure they could be fixed i.e bootstrap was upgraded to 4.3.1 but there's code that references bootstrap 3.3.7 (see pic ... I don't think the flash of validation is supposed to work that way). If I'm able to fix these while I learn more about this vertical slice architecture, I'll create a PR.
error with validation

@TDK1964
Copy link

TDK1964 commented Jun 12, 2021

I needed to move the following scripts to the header in order for it to work.
Don't know why this should make a difference but it did.

<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/lodash/dist/core.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
<script src="~/js/site.js"></script>

@cdgipson
Copy link

Something in this method or sub-methods was throwing an error stating that it could not find _.reject(). I found this by adding the alert statement to the catch.

var highlightErrors = function (xhr) {
    try {
        var data = JSON.parse(xhr.responseText);
        highlightFields(data);
        showSummary(data);
        window.scrollTo(0, 0);
    } catch (e) {
        alert(e);
        // (Hopefully) caught by the generic error handler in `config.js`.
    }
};

To fix this, I had to replace the following.

<script src="~/lib/lodash/dist/core.js"></script>

with this

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants