user1023110 user1023110 - 1 month ago 7
jQuery Question

jquery-ui isn't loading ui images properly in grails

Having some trouble with the images that come with jquery-ui, which show up as 404-not found in the chrome inspector.

enter image description here

However, these files are actually in the right plact assets/images directory of my application:

enter image description here

The network table on the inspector, though seems to indicate some problem regarding the file type:

enter image description here

It looks like jquery is trying to load these pngs as text. Could that be why there is a problem locating the file

anybody know how to resolve this problem?

Answer

RVargas asked a good question which is where are other assets being loaded form in the page. Interestly, my javascripts, which live in the grails-app/assets/stylesheet directory are being loaded as follows:

<script type="text/javascript" src="/assets/jquery-2.2.0.min.js?compile=false"></script>

Notice no reference to the 'stylesheet' subdirectory. So apparently grails is somehow resolving all assets as if they all lived in the assets directory not the individual subfolder javascripts/images/stylesheets. Apparently jquery-ui doesn't know this so it looks for image assets in assets/images/ subdirectory.

In order to get jquery-ui working properly I had to create an images directory under assets/javascripts e.g. assets/javascripts/images and put the jquery image assets in there for the app to be able to find them using the assets/images url.