Embedding JavaScript that contains '<'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Embedding JavaScript that contains '<'

Andrew McQuiggin
Hi,

Just trying out some jQuery Mobile from Amber, I tried embedding the statements below:

<$('#header1').append($('<input id="Button1" type="button" value="Custom button" />'))>.
        <$('#header1').trigger('create')>

Even though the html to be appended by the first statement is coloured as a string in the Amber browser, there is a parse error on saving while either the "<" or "/>" are present (but not if they are removed). Is this a bug or am I not using the necessary syntax to handle this situation?

Thanks,

     Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Embedding JavaScript that contains '<'

Andrew McQuiggin
As soon as I sent this question, the tactical solution occurred to me:

buttonString := '<input id="Button1" type="button" value="Custom button" />'.
<$('#header1').append($(buttonString))>.
        <$('#header1').trigger('create')>

...put the html string into a local variable, then pass that local variable to be appended to the header. Sure enough, the button is dynamically added to my JQM view - but should I have to go through this intermediate step?

Andrew

On 22 June 2012 00:35, Andrew McQuiggin <[hidden email]> wrote:
Hi,

Just trying out some jQuery Mobile from Amber, I tried embedding the statements below:

<$('#header1').append($('<input id="Button1" type="button" value="Custom button" />'))>.
        <$('#header1').trigger('create')>

Even though the html to be appended by the first statement is coloured as a string in the Amber browser, there is a parse error on saving while either the "<" or "/>" are present (but not if they are removed). Is this a bug or am I not using the necessary syntax to handle this situation?

Thanks,

     Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Embedding JavaScript that contains '<'

Nicolas Petton
Andrew McQuiggin <[hidden email]> writes:

Hi!

You can escape with >>

Cheers,
Nico

> As soon as I sent this question, the tactical solution occurred to me:
>
>
> buttonString := '<input id="Button1" type="button" value="Custom
> button" />'.
> <$('#header1').append($(buttonString))>.
>         <$('#header1').trigger('create')>
>
> ...put the html string into a local variable, then pass that local
> variable to be appended to the header. Sure enough, the button is
> dynamically added to my JQM view - but should I have to go through
> this intermediate step?
>
> Andrew
>
> On 22 June 2012 00:35, Andrew McQuiggin <[hidden email]> wrote:
>
>     Hi,
>    
>    
>     Just trying out some jQuery Mobile from Amber, I tried embedding
>     the statements below:
>    
>    
>    
>     <$('#header1').append($('<input id="Button1" type="button"
>     value="Custom button" />'))>.
>             <$('#header1').trigger('create')>
>    
>    
>     Even though the html to be appended by the first statement is
>     coloured as a string in the Amber browser, there is a parse error
>     on saving while either the "<" or "/>" are present (but not if
>     they are removed). Is this a bug or am I not using the necessary
>     syntax to handle this situation?
>    
>    
>     Thanks,
>    
>    
>          Andrew
>
>

--
Nicolas Petton
http://nicolas-petton.fr