سؤال

I am trying to add a line break to a jQuery parameter string. I have tried \n and + \n + and <br />. Any of these break it. Here is a sample of the code.

$(function() {
    $('#products').grid({
        'items' :
        [
            {
            'title'       : '256 Alaskan',
            'description' : 'Production Plant: Summit | Color Classification: Heritage Series | Size Availability: Stock: Standard *special order - queen, modular thin | Texture Availability: Grain',
            'thumbnail'   : ['assets/images/products/thumbs/alaskan.jpg', 'assets/images/products/thumbs/alaskan.jpg'],
            'large'       : ['assets/images/products/fullsize/alaskan.jpg', 'assets/images/products/fullsize/alaskan.jpg'],
            'button_list' : [],
            'tags'        : ['White']
        },
});

So in the 'description' parameter, it can only take one long string sourounded by single quotes of course. Is there any way for me to add a line break where I have put the | (pipe) symbols? I have tried separating into mulitiple strings but it just breaks. Any thoughts? Appreciate the help.

هل كانت مفيدة؟

المحلول

So I found the solution! After further digging I found the function call that creates the 'description' parameter, which was basically:

this.$description = $( '<p></p>' ); 

By simply adding a

<br /> 

into the full string itself I was able to create the line breaks successfully. I think initially it was not working because I was doing it like:

'Production Plant: Summit' + '<br />' + 'Color Cassification: Heritage Series',

when all it really needed was:

 'Production Plant: Summit <br /> Color Cassification: Heritage Series'.

Hope this helps out someone else in the future. Thanks for the responses.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top