chris loughnane
chris loughnane

Reputation: 2748

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

Upvotes: 1

Views: 158

Answers (2)

thecodeparadox
thecodeparadox

Reputation: 87073

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'
}

Upvotes: 1

Christoph
Christoph

Reputation: 51211

Besides the fact, that I can't see the attr option for the content property (Documentation) (might be another version or whatever), i guess it should be:

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

(spaces are not allowed in id attributes) instead of

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

since you don't want to alter the name of the option (which is fixed attr) but the value of it.

Upvotes: 1

Related Questions