开发者

Calling a function within a array

开发者 https://www.devze.com 2023-01-15 00:17 出处:网络
How do I go about calling a function within a jQuery array to add another开发者_运维知识库 array?

How do I go about calling a function within a jQuery array to add another开发者_运维知识库 array?

$('#map').zoommap({

        // Width and Height of the Map
        width: '490px',
        height: '380px',

        //Region
        map: function getMaps();

    });

getMaps() should return the following:

{
    id: 'campus',
    image: '/resources/images/maps/'+mapId,
    data: '',
    maps: []
}

Cheers, Nick


Pretty sure

map: getMaps()

Will do the trick. No ; at the end (just a comma if you need to add more items), and you don't need to put function before it either, unless you're trying to declare a function.

If you're questioning how to write the getMaps() function, you pretty much have that too..

function getMaps() {
    return {
        id: 'campus',
        image: '/resources/images/maps/'+mapId,
        data: '',
        maps: []
    }
}

Although I don't know why you need the function at all, when you could just put the inner { id: ... } right in it's place.... putting it all together:

$('#map').zoommap({
    // Width and Height of the Map
    width: '490px',
    height: '380px',

    //Region
    map: {
        id: 'campus',
        image: '/resources/images/maps/'+mapId,
        data: '',
        maps: []
    }
});


$('#map').zoommap({

        // Width and Height of the Map
        width: '490px',
        height: '380px',

        //Region
        map: getMaps()

    });
0

精彩评论

暂无评论...
验证码 换一张
取 消