• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Formatting problem

 
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a strange problem that I think is a result of using the jquery $.load() method. I include an html fragment into a page with this method.The problem I am having is that even though the text has proper spacing and paragraphs, this all lost once it is loaded...The only way that I can get the text to appear formatted correctly is by hardcoding it into a table!!

Please can anyone advise me what is wrong....
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Duran Harris wrote:... even though the text has proper spacing and paragraphs, this all lost once it is loaded


What do you mean by this? What are you using for "proper spacing and paragraphs"? If it's whitespace, HTML ignores whitespace.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As this has nothing whatsoever to do with Ajax or jQuery, I've adjusted the title.
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The exact problem is that the text doesn't always start exactly on the left hand margin.It's as if each line has a slightly different margin-lefty property(if lines had a margin-left property)The page in question can be viewed at http:\\drfishspamorningside.co.za and then clicking on the 'History' button.(You can use firebug to monitor the XHR requests/responses).This hasn't really been a problem until I needed to include such a large chunk of text.

I have tried </BR>'s, <p>'s,printing out the text on the server-side(with newlines)..but nothing seems to work.I am simply calling jQuery's .load on a div to load the content in.
[/code]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without looking at the source code, your text is center aligned. lol

Eric
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so I visited the page -- by the way, URLs use forward slashes, not back-slashes.

The text is center-justified, which is why the margins are ragged. The Contacts page has the same problem.

This has nothing to do with Ajax, or jQuery, or load(). It's a CSS issue. Find out why the alignment is set to center.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might be your problem:

a) Use CSS rather than element attributes for styling

b) If you tell something to be centered, why the surprise when it is?
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! It's fixed now(Well almost)!

Oh and @Bear: I am trying to get in the habit of using CSS for styling.I generally only use it if it can save me some typing though!
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a habit you should work hard on changing.
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is only the 2nd time I've used my own stylesheet, only since your book helped me understand how selectors work.But I honestly didn't expect align=center to mess with text like that!Now I know, thanks!
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's one of the reasons that mixing CSS and style markup is to be avoided. It's like two left feet dancing -- someone is going to get stepped on.
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyway, enjoy the long weekend(It's a long weekend for Easter here in South Africa,don't know if all countries have a long weekend now, although that would make sense since you can't exactly go and celebrate the resurrection of Christ late.That would be cheeky) :p
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope, no long weekend for me. But thanks for the good wishes!
 
mooooooo ..... tiny ad ....
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic