[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread dirk w

hello liam,
thanks for the tip, i will try using them the same way.
you actually forgot one  in your code but now it works fine, thanks!

$(#searchResultList).append('li class=searchResultEntry id=' +
videoId + ' title=' + titleFull + ' (' + minutes + ':' + seconds
+')img src=' + thumbnailUrl + ' class=thumbnail alt=' +
titleFull + ' (' + minutes + ':' + seconds + ')//li');

On 4 Feb., 15:51, Liam Potter radioactiv...@gmail.com wrote:
 you need to switch it around,

 replace all  to be ' and all ' to be 

 Personally, all my selectors use 
 then functions use '

 $(#searchResultList).append('li class=searchResultEntryid=' + videoId + 
 ' title=' + titleFull + ' (' + minutes + ':' + seconds +')'img src=' + 
 thumbnailUrl + '       class=thumbnail alt=' + titleFull + ' (' + minutes 
 + ':' + seconds + ')//li');

 that's how I would do this.

 dirk w wrote:
  hello jquery community,
  i am getting some strings from a page i don't have influence on. i
  just append those to elements (thanks to jquery this works like a
  charm!):

  $(#searchResultList).append(li class='searchResultEntry'id=' +
  videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
  )'img src=' + thumbnailUrl + '   class='thumbnail' alt=' +
  titleFull +  ( + minutes + : + seconds + )'//li);

  my problem is:
  sometimes the variable title contains a ' in the string, like
  doesn't that look funny... in this case my output get's completely
  messed up.
  is there a more reliable way to use ' and   ? any ideas how i could
  prevent ' to crack this up?

  thanks in advance
  dirk


[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread Liam Potter


Glad to of helped.
My system has worked for me so far, but I'm sure there are people who 
would argue another way of doing things.


dirk w wrote:

hello liam,
thanks for the tip, i will try using them the same way.
you actually forgot one  in your code but now it works fine, thanks!

$(#searchResultList).append('li class=searchResultEntry id=' +
videoId + ' title=' + titleFull + ' (' + minutes + ':' + seconds
+')img src=' + thumbnailUrl + ' class=thumbnail alt=' +
titleFull + ' (' + minutes + ':' + seconds + ')//li');

On 4 Feb., 15:51, Liam Potter radioactiv...@gmail.com wrote:
  

you need to switch it around,

replace all  to be ' and all ' to be 

Personally, all my selectors use 
then functions use '

$(#searchResultList).append('li class=searchResultEntryid=' + videoId + ' title=' + titleFull + ' (' + minutes + ':' 
+ seconds +')'img src=' + thumbnailUrl + '   class=thumbnail alt=' + titleFull + ' (' + minutes + ':' + seconds + 
')//li');

that's how I would do this.

dirk w wrote:


hello jquery community,
i am getting some strings from a page i don't have influence on. i
just append those to elements (thanks to jquery this works like a
charm!):
  
$(#searchResultList).append(li class='searchResultEntry'id=' +

videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
)'img src=' + thumbnailUrl + '   class='thumbnail' alt=' +
titleFull +  ( + minutes + : + seconds + )'//li);
  
my problem is:

sometimes the variable title contains a ' in the string, like
doesn't that look funny... in this case my output get's completely
messed up.
is there a more reliable way to use ' and   ? any ideas how i could
prevent ' to crack this up?
  
thanks in advance

dirk
  


[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread Liam Potter


you need to switch it around,

replace all  to be ' and all ' to be 

Personally, all my selectors use 
then functions use '

$(#searchResultList).append('li class=searchResultEntryid=' + videoId + ' title=' + titleFull + ' (' + minutes + ':' 
+ seconds +')'img src=' + thumbnailUrl + '   class=thumbnail alt=' + titleFull + ' (' + minutes + ':' + seconds + 
')//li');

that's how I would do this.






dirk w wrote:

hello jquery community,
i am getting some strings from a page i don't have influence on. i
just append those to elements (thanks to jquery this works like a
charm!):

$(#searchResultList).append(li class='searchResultEntry'id=' +
videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
)'img src=' + thumbnailUrl + 'class='thumbnail' alt=' +
titleFull +  ( + minutes + : + seconds + )'//li);

my problem is:
sometimes the variable title contains a ' in the string, like
doesn't that look funny... in this case my output get's completely
messed up.
is there a more reliable way to use ' and   ? any ideas how i could
prevent ' to crack this up?

thanks in advance
dirk
  


[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread Ricardo Tomasi

Replace all quotes inside your text variables with their correspondent
HTML entities, then you should face no issues:

titleFull = titleFull.replace(',#145;).replace('',quot;);

I agree with Liam, it's best to use single quotes for the strings
passed so you can use double quotes inside them. In XHTML all atribute
values should use double quotes.

- ricardo

On Feb 4, 12:44 pm, dirk w dirkwendl...@googlemail.com wrote:
 hello jquery community,
 i am getting some strings from a page i don't have influence on. i
 just append those to elements (thanks to jquery this works like a
 charm!):

 $(#searchResultList).append(li class='searchResultEntry'id=' +
 videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
 )'img src=' + thumbnailUrl + '        class='thumbnail' alt=' +
 titleFull +  ( + minutes + : + seconds + )'//li);

 my problem is:
 sometimes the variable title contains a ' in the string, like
 doesn't that look funny... in this case my output get's completely
 messed up.
 is there a more reliable way to use ' and   ? any ideas how i could
 prevent ' to crack this up?

 thanks in advance
 dirk


[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread Patrick Jarrett

There is nothing wrong with it, but it's far from perfect. By making
the switch you're no longer at risk from 's but now if the string
contains any s you'll have the same problem all over again.

Ideally you'd first run a replace on the string you fetch from the
other site, replacing all 's with \'s. The \ here escapes the ' and
makes javascript read it as a part of the string rather than the end
of it.

-- Patrick

On Wed, Feb 4, 2009 at 10:19 AM, Liam Potter radioactiv...@gmail.com wrote:

 Glad to of helped.
 My system has worked for me so far, but I'm sure there are people who would
 argue another way of doing things.

 dirk w wrote:

 hello liam,
 thanks for the tip, i will try using them the same way.
 you actually forgot one  in your code but now it works fine, thanks!

 $(#searchResultList).append('li class=searchResultEntry id=' +
 videoId + ' title=' + titleFull + ' (' + minutes + ':' + seconds
 +')img src=' + thumbnailUrl + ' class=thumbnail alt=' +
 titleFull + ' (' + minutes + ':' + seconds + ')//li');

 On 4 Feb., 15:51, Liam Potter radioactiv...@gmail.com wrote:


 you need to switch it around,

 replace all  to be ' and all ' to be 

 Personally, all my selectors use 
 then functions use '

 $(#searchResultList).append('li class=searchResultEntryid=' +
 videoId + ' title=' + titleFull + ' (' + minutes + ':' + seconds +')'img
 src=' + thumbnailUrl + '   class=thumbnail alt=' + titleFull + ' ('
 + minutes + ':' + seconds + ')//li');

 that's how I would do this.

 dirk w wrote:


 hello jquery community,
 i am getting some strings from a page i don't have influence on. i
 just append those to elements (thanks to jquery this works like a
 charm!):
  $(#searchResultList).append(li class='searchResultEntry'id=' +
 videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
 )'img src=' + thumbnailUrl + '   class='thumbnail' alt=' +
 titleFull +  ( + minutes + : + seconds + )'//li);
  my problem is:
 sometimes the variable title contains a ' in the string, like
 doesn't that look funny... in this case my output get's completely
 messed up.
 is there a more reliable way to use ' and   ? any ideas how i could
 prevent ' to crack this up?
  thanks in advance
 dirk




[jQuery] Re: having a problem with ' and strings

2009-02-04 Thread Ricardo Tomasi

My friend Mauricio Samy pointed out a mistake I made: attributes
enclosed in single quotes are actually valid in XHTML/XML.

I'm used to single quotes as a standard for JS, and double ones for
XHTML, makes code clearer in both.

cheers,
- ricardo

On Feb 4, 3:56 pm, Ricardo Tomasi ricardob...@gmail.com wrote:
 Replace all quotes inside your text variables with their correspondent
 HTML entities, then you should face no issues:

 titleFull = titleFull.replace(',#145;).replace('',quot;);

 I agree with Liam, it's best to use single quotes for the strings
 passed so you can use double quotes inside them. In XHTML all atribute
 values should use double quotes.

 - ricardo

 On Feb 4, 12:44 pm, dirk w dirkwendl...@googlemail.com wrote:

  hello jquery community,
  i am getting some strings from a page i don't have influence on. i
  just append those to elements (thanks to jquery this works like a
  charm!):

  $(#searchResultList).append(li class='searchResultEntry'id=' +
  videoId + ' title=' + titleFull +  ( + minutes + : + seconds +
  )'img src=' + thumbnailUrl + '        class='thumbnail' alt=' +
  titleFull +  ( + minutes + : + seconds + )'//li);

  my problem is:
  sometimes the variable title contains a ' in the string, like
  doesn't that look funny... in this case my output get's completely
  messed up.
  is there a more reliable way to use ' and   ? any ideas how i could
  prevent ' to crack this up?

  thanks in advance
  dirk