From 59be99f9f8b835cb76a8a1abe3a1a0abf8306f56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"J.=20Rene=CC=81e=20Beach"?= <splendidnoise@gmail.com>
Date: Wed, 24 Jul 2013 16:42:14 -0400
Subject: [PATCH] Issue #2014893 by jessebeach: Multiple quick edit links
 inserted into the contextual links when an field is edited
 and saved.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: J. Renée Beach <splendidnoise@gmail.com>
---
 core/modules/edit/js/edit.js |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/core/modules/edit/js/edit.js b/core/modules/edit/js/edit.js
index 498865e..dc0bf16 100644
--- a/core/modules/edit/js/edit.js
+++ b/core/modules/edit/js/edit.js
@@ -382,8 +382,11 @@ function initializeEntityContextualLink (contextualLink) {
     });
     fieldsAvailableQueue = _.difference(fieldsAvailableQueue, fields);
 
-    // Set up contextual link view after loading any missing in-place editors.
-    loadMissingEditors(function () {
+    /**
+     * Initialization should only be called once. Use underscore's once method
+     * to get a one-time use version of the function.
+     */
+    var initContextualLink = _.once(function () {
       var $links = $(contextualLink.el).find('.contextual-links');
       var contextualLinkView = new Drupal.edit.ContextualLinkView($.extend({
         el: $('<li class="quick-edit"><a href=""></a></li>').prependTo($links),
@@ -393,6 +396,9 @@ function initializeEntityContextualLink (contextualLink) {
       entityModel.set('contextualLinkView', contextualLinkView);
     });
 
+    // Set up contextual link view after loading any missing in-place editors.
+    loadMissingEditors(initContextualLink);
+
     return true;
   }
   // There was not at least one field that the current user may edit in-place,
-- 
1.7.10.4

