Search code examples
jqueryattrqtip

qtip - how to - content: { "prepend some text to an" attr : 'id'},


I have this working for my qtip

        /* required for qtip crests to crests */
        var countyCrest =   {
                content: {
                    attr: 'id'
                },
                position: {
                    target: 'mouse',
                    adjust: {
                        mouse: true,
                        y: +10
                    }
                },
                style: {
                    classes: 'ui-tooltip-tipsy ui-tooltip-shadow',
                    tip: true
                }
        };/* end for qtip crests to crests */

and I would like to prepend "Co. " before each attr: 'id'. I tried various versions of

content: {
            "Co. "+attr: 'id'
},

which does not work. Could anyone point me in the right direction? tia


Solution

  • Better would be like following:

    var temp = {};
    
    temp['Co. ' + attr] = 'id'; 
     var countyCrest =   {
    
         content: temp,
        ...
    }
    

    DEMO


    Note

    String concatenation of Object property as you tried is not possible.


    If you want answer like @Christoph then you don't need concatenation, write simply like

    content: {
                attr: 'Co.id'
    }