0
votes

I'm having a lot of trouble with JavaScript elements in themes. All of my CSS is loading correctly, but my JavaScript doesn't seem to be.

I'm working with a combination of resource JS files uploaded as resources to the Database, JavaScript script libraries, server-stored JavaScript files, and Javascript files at http locations.

I've tried setting content-type to application/x-javascript, but that doesn't seem to work. Anything uploaded as a file resource I'm able to include by omitting the content-type, but if I add the content-type, it becomes invalid.

Example:

<resource>
    <href>anytime.js</href>
</resource>

Will show up as /anytime.js"> when the page renders, but

<resource>
    <content-type>application/x-javascript</content-type>
    <href>anytime.js</href>
</resource>

doesn't render anything.

Additionally, trying to access something remote, like http://code.jquery.com/jquery-1.7.1.js doesn't work either way. Both omitting the content type and setting it to application/x-javascript result in nothing rendering to the browser. I'm hoping someone will be able to help me out with this one.

2
Minor update: I deleted a number of other entries in my theme, and removed the content type from the absolute linked entry to jquery.com, which now renders. Is it possible that setting the content type is a bad idea?Aaron Brake
No, setting the correct content type is mandatory. Did you delete your theme resource and re-created again with another name? Sounds like a problem in your structure so your theme does not compile correctly. Which release of Domino Designer do you use?Oliver Busse
Oliver: It looks like it was a problem with formatting, as I attempted to detail below. However, I find it interesting that it was correctly interpreting my resources without the addition of a content type.Aaron Brake

2 Answers

2
votes

This is an attempt you answer your question on auto-formatting that you ask in your own answer. So this is not an attempt to answer the original question.

Yes, you can control what auto-formatting does.

For instance, you can control the XML editor auto formatting in Domino Designer Preferences under XML - XML Files - Editor. This controls XPages, custom control, themes and faces-config editing. Here you can control line width and whether to split multiple attributes each on a new line.

You can also control Java formatting in Domino Designer Preferences under Java - Code Style - Formatter. Here you can edit the existing profile or create your own profile and edit that.

I am sure there are several other places in Preferences that could be useful. Lessons learned is that whenever auto-formatting does something, you can change its behaviour.


Have a look at Nathan Freemans "Making Domino Designer work like you want" for more useful stuff that you can change in Preferences.

1
votes

Okay, so, after some more testing and frustration, I figured out what's going on here. After I'd enter the code, I was doing ctrl+alt+F to auto-format the code so that the indentation would be consistent. This was causing the closing tag for to appear on the second line, like so:

<resource>
    <href>URL
    </href>
</resource>

If I try to render it like this, it doesn't work. So, it wasn't an issue of css vs js, but rather file length. Though that does make me wonder if there's any way to change the line length threshhold settings on the auto-format?