Why I need add “data: {type: ”script“}” on remote link with rails / ajax

后端 未结 3 1225
梦如初夏
梦如初夏 2021-01-18 19:31

in one project of mine, the code:

  = link_to \"add\", new_me_category_path, class: \"btn btn-success\", remote: true

can load remote form

3条回答
  •  天命终不由人
    2021-01-18 20:03

    If you loading script correct template should have .ejs extension (or render raw script like this: render js: 'some code'). You must escape html using j in ejs template like this:

    template.ejs

    $('some selector').html('<%= j render('some template') %>');
    

    Please give me also url. Correct one should end with .js.

提交回复
热议问题