Note that there are some explanatory texts on larger screens.

plurals
  1. PORails - @mentions using at.js
    primarykey
    data
    text
    <p>I've been trying to implement @mentions for my application using the At.js library from</p> <p><a href="https://github.com/ichord/At.js" rel="nofollow">https://github.com/ichord/At.js</a></p> <p>I'm having some issues triggering the at functionality (triggered by the callback in the code below). I have setup the following coffeescript:</p> <pre><code>$ -&gt; $("textarea").atWho "@", (query, callback) -&gt; console.log("@who") $.ajax url: "/users/mentions.json" param: q: query done: (data) -&gt; console.log("in callback") console.log(data) names = $.parseJSON(data) console.log(names) callback names </code></pre> <p>From the js and rails consoles I can see that the controller action is getting called, however no other calls are made. </p> <p>This library has been working fine for me with static data so I think that the callback syntax is an issue. Does anyone have any pointers for this?</p> <p>EDIT:</p> <p>I've adapted Nick's solution below and changed to use a get request and this works fine for querying and returning data from the rails app using the following revised code:</p> <pre><code>$ -&gt; $("textarea").atWho "@", (query, callback) -&gt; console.log("@who") $.get "/users/mentions.json", q: query, ((result) -&gt; console.log("in callback") console.log("result: ") console.log(result) names = $.parseJSON(result) console.log(names) callback names ), "json" </code></pre> <p>However there is still a problem with the parseJSON(result) line - it returns null every time. I have tried changing the json which I am sending to the very simple {"name":"james"} and it is still not returning anything - can anyone help with this issue?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload