jQuery Mobile Autodivider Not Formatting Correctly - Using Hot Towel Views
Asked Answered
I

1

2

I'm trying to get my list to look like this:

enter image description here

But it looks like this:

enter image description here

I've copied the code directly from the jQuery mobile site:

<ul data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
    <li><a href="index.html">Adam Kinkaid</a></li>
    <li><a href="index.html">Alex Wickerham</a></li>
    <li><a href="index.html">Avery Johnson</a></li>
    <li><a href="index.html">Bob Cabot</a></li>
    <li><a href="index.html">Caleb Booth</a></li>
    <li><a href="index.html">Christopher Adams</a></li>
    <li><a href="index.html">Culver James</a></li>
</ul>

And my bundles have the js and css files:

bundles.Add(
              new ScriptBundle("~/scripts/vendor")
                .Include("~/scripts/jquery-{version}.js")
                .Include("~/scripts/jquery.mobile-{version}.js")

bundles.Add(
              new StyleBundle("~/Content/css")
                .Include("~/Content/ie10mobile.css")
                .Include("~/Content/jquery.mobile-{version}.css")
                .Include("~/Content/jquery.mobile.structure-{version}.css")
                .Include("~/Content/jquery.mobile.theme-{version}.css")

However, I cannot get my list to look like it's supposed to. What could I be missing?

Note: When viewing the F12 window in chrome, I don't see any errors, but there is a little warnings icon at the bottom-right of the window:

enter image description here

But nothing happens when I click on it. I've also pasted that same code into jsfiddle.net and it works just fine there. I just can't get it to work in my app.

Edit - jQuery versions

enter image description here

Edit 2 - Errors?

I just noticed this in developer tools. Could this have something to do with it? Does the strikethrough mean the browser had trouble loading something?

enter image description here

Edit 3 - Hot Towel structure causing issue?

If I put that same HTML in my index.cshtml file, it works. But when I try to put it in any of the hot towel views (app folder, views folder) it just doesn't render. Maybe there is something about that folder structure that isn't allowing the css to be found?

Edit 4 - Viewing source for when it works vs when it doesn't

If I put the list on index.cshtml and inspect it in dev tools, I can see all of the styles applied:

enter image description here

But on the other view (in the app\views folder), it's just plain:

enter image description here

Edit 5 - CSS used on index.cshtml

I have the same list on index.cshtml and on apps.html. These styles show up for the list on index.cshtml, but they don't exist for the list on apps.html. For apps.html, it's not that the styles are crossed off, they're just not there.

enter image description here

Impeccant answered 8/9, 2013 at 16:1 Comment(5)
I don't think you need to include structure and theme (last two libraries) unless you're using a custom css made by theme roller.Preterition
@Preterition Thanks. I just had them in there because I was trying to make things work.Impeccant
Listview stilll not rendered as it should?Preterition
Can you verify via view source that the bundled scripts and styles are being correctly inserted. Also, consider dropping the various data options (other than data-role="listview" from your <ul> and make sure the basics are working. Lastly, what version of jQM are you using?Dorree
@Dorree I checked the page source and the scripts and styles are indeed there. What's weird though is that the list doesn't show in the page source. I'm using jQM 1.3.2.Impeccant
S
2

The CSS is cascading, so if the CSS has a strikethrough that means something else overrode it. That could mean something came after it that had the same class, something came before/after it that has a more precise match, or something was listed as !important. To find out what is causing it you can look at the right hand side of Chrome tools to see which styles are coming from where. Or you can scroll up and down the list that you showed and look for it there.

Finally, you can test it by adding !important to the strikethrough rules to see if they get applied (just to test it).

Serajevo answered 9/9, 2013 at 19:58 Comment(8)
+1 for the tip. I'm struggling to make sense of the styles window in dev tools. There are quite a few css files listed, and some show up many times. I'm not sure how that tells me why the style isn't getting applied. And I'm not sure how to mark one as !important. I'll keep digging.Impeccant
In the Chrome dev tools, double click on the style and you can edit it. Add !important at the end.Serajevo
Does my Edit 5 help clarify anything? I'm not sure what else to try.Impeccant
Sorry, no. Could you create a jsfiddle or plnkr with the code so we can run it and see the issue? If you do that, I'll take a look and see what I can find.Serajevo
It looks good here, with jQuery.Mobile selected: jsfiddle.net/rCzU8. If I uncheck jQuery.Mobile, the output looks like what I'm getting on my apps.html page, which is in the App\views folder. It's like somehow that view isn't able to use jQuery.Mobile. Is there anything special that needs to be done in a hot towel app to get views in the App\views folder to access jQuery.Mobile?Impeccant
It works in the fiddle. So this certainly looks like a CSS precedence issue as I mentioned previously. You need to debug the CSS using the Chrome (or your favorite) dev tools to see why your CSS is not being applied.Serajevo
I just thought of something. Presto (the app) is open source. You could open the solution and see it run. I know this is a lot to ask, so I understand if you stop responding. If you're willing to take a look: presto.codeplex.com/SourceControl/latest. The solution is in Main\Solutions\Presto. And the web project is Source\Client\PrestoWeb. Even if you don't look, thanks for your help so far. I'll keep plugging away.Impeccant
I think I have a quick and easy way for you to see this behavior. I just created a new MVC app using the hot towel template. All I did was add the nuget packages for hot towel and jQuery.Mobile (and added jQuery.Mobile to the js and css bundles). If you put that <ul> section (see the HTML in my question) in index.cshtml (in Views\HotTowell) and in home.html (in App\views), you'll see that it renders correctly in index.cshtml but not home.html.Impeccant

© 2022 - 2024 — McMap. All rights reserved.