Note that there are some explanatory texts on larger screens.

plurals
  1. POAbout Jeditable jquery plugin in the context of Backbone.View
    primarykey
    data
    text
    <p>Using the <a href="http://www.appelsiini.net/projects/jeditable" rel="nofollow">Jeditable</a> plugin,<br> is possible to create, very easily, a submit and cancel button.<br> Here's a very simple code example (*)</p> <p>Now let's suppose in <code>MyView</code> (Backbone.View) I would like to trigger the event click on the button submit which is created by Jeditable.<br> Here's the code regarding the <code>Backbone.View</code> (**). </p> <p>When I trigger the event <code>"click .submitBtn"</code> the value of $('.edit_area').text is empty string. In order to fix this issue I implemented the following code (* **)</p> <p>Do you have some smart idea to improve the code of (* **)? I don't like callback using <code>setTimeout</code>.</p> <hr> <p>(*)</p> <pre><code> $('.edit_area').editable(function(value, settings) { return(value); }, { type : 'textarea', submit : '&lt;div class="submitBtn"&gt;Ok&lt;/div&gt;' cancel : '&lt;div class="submitBtn"&gt;Undo&lt;/div&gt;' }); </code></pre> <hr> <p>(**)</p> <pre><code>MyView = Backbone.View.extend({ events: { "click .edit_area" : "edit", "click .submitBtn" : "close" }, }); </code></pre> <hr> <p>(* **)</p> <pre><code>close: function close () { var that = this; console.log($(this.el).find("[data-tid='editable']").text()); // empty string setTimeout(function () { console.log($(that.el).find("[data-tid='editable']").text()); // update string that.model.save({ name: $(that.el).find("[data-tid='editable']").text() }); }, 0); }, </code></pre>
    singulars
    1. This table or related slice is empty.
    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