0

I'm making a mobile web app with Backbone.js and jQuery Mobile but I'm having some styling issues. Just to test things out I wanted to style my Logout button. Before styling, I had:

this.$el.append('<input type="button" id="logoutButton" value="Logout">');

at a certain point at my code, which had been working fine. I changed this line to:

this.$el.append('<a href="" data-role="button" data-theme="c" data-inline="true" id="logoutButton"> LOGOUT </a>');

But, when I do this, it just displays "LOGOUT" as a plain link with no CSS applied. I tried putting the same code in the body of my HTML file instead of inserting it with JS and it was styled correctly. I load my CSS file in the head of my document before all other files and my JS code is contained in a function bound to $(document).ready() so I'm not sure why the CSS is not working.

Am I missing something conceptual? How can I fix this?

2
  • can you post the css code? Commented Jul 15, 2013 at 21:08
  • @AbrahamUribe, all the CSS code I have at the moment is just the jQM CSS file, unedited. Commented Jul 16, 2013 at 2:01

1 Answer 1

2

I think you need to use buttonMarkup to refresh styling like this :

$("#one").append('<a href="" data-role="button" data-theme="c" data-inline="true" id="logoutButton"> LOGOUT </a>')
$("#logoutButton").buttonMarkup("refresh");

Where #one is just a random page in HTML.

Demo : http://jsfiddle.net/hungerpain/tEnet/

And DONT USE ready event with jQM.

Sign up to request clarification or add additional context in comments.

1 Comment

Great, I'll try that tomorrow and see how it works. And thanks for the tip about the ready event. Wouldn't have thought of that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.