Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this <a href="http://jsfiddle.net/g6vXf/6/" rel="noreferrer">jsfiddle</a></p> <p>HTML:</p> <pre><code>&lt;form&gt; &lt;textarea class="messageTextarea"&gt;Write your comment here...&lt;/textarea&gt; &lt;/form&gt;​ </code></pre> <p>JS:</p> <pre><code> $('.messageTextarea').keydown(function(event) { if (event.keyCode == 13) { $(this.form).submit() return false; } }).focus(function(){ if(this.value == "Write your comment here..."){ this.value = ""; } }).blur(function(){ if(this.value==""){ this.value = "Write your comment here..."; } }); $("form").submit(function(){ var name = $(this).siblings('.messageTextarea').val(); var theid = $(this).attr('data-the_id'); var dataString = name; $.ajax({ dataType: 'json', url: "https://api.instagram.com/v1/media/"+$(this).attr('data-the_id')+"/comments?", type: "POST", data: "text="+dataString, success: function(data) { // finish load console.log(data, dataString, 'fail'); }, error: function(data) { var username = JSON.parse(localStorage.getItem('iguser')); var profilepic = JSON.parse(localStorage.getItem('iguserimg')); //console.log(data, dataString, 'succ'); $('.box[data-the_id="' + theid + '"]').children('.postMessage').children('.messageComments').append('&lt;li&gt;&lt;img class="commentUserImg" src="' + profilepic + '"&gt;&lt;div class="commentUser"&gt;' + username + '&lt;/div&gt;&lt;div class="commentText"&gt;' + dataString + '&lt;/div&gt;&lt;/li&gt;'); $('.messageTextarea').val(''); // Remove comment from TextArea } }); return false; }); ​ ​ </code></pre> <p>​</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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