如何将多个项目传递给车把中的功能?

时间:2017-12-02 19:31:30

标签: javascript jquery handlebars.js

我的手柄文件中出现以下错误 -

" .K =" deleteTypePoke({{pokemon_pokemonid,TY ----------------------- ^ 期待ID',' STRING',' NUMBER',' BOOLEAN'' UNDEFINED',' NULL',' DATA',得到'无效'"

句柄不允许我传入我的两个变量,可能是由于逗号

           {{#each typehaspokemon}}
            <tr>
                    <td>{{pokemonname}}</td>
                    <td>{{typename}}</td>
                    <td><button onclick="deleteTypePoke({{pokemon_pokemonid,type_typeid}})">Delete</button></td>
            </tr>
            {{/each}}

这是我的javascript文件

function deleteTypePoke(pokemon_pokemonid, type_typeid){
        $.ajax({
                url: '/typehaspokemon/' + pokemon_pokemonid + '&' + type_typeid,
                type: 'DELETE',
                success: function(result){
                        window.location.reload(true);
                        }
                })
};

如何通过把手将口袋妖怪ID和类型ID传递给此功能?

1 个答案:

答案 0 :(得分:1)

你试过这个吗?:

<button onclick="deleteTypePoke({{pokemon_pokemonid}},{{type_typeid}})">Delete</button>