Quick Edit menu item is not shown. Instead, I get:

Uncaught TypeError: Cannot call method 'getAttribute' of undefined at: .getAttribute('data-edit-entity-instance-id');

The status report page is all green.

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Spark

I've already explained in #2154891-8: Quick Edit contextual link not shown.2 why this happens:

  1. For certain node types, e.g. the "business" node type (e.g. http://greekafm.com/afm/800395529), it seems a custom template is in place that prevents the essential data-edit-entity-id attribute that Edit sets from making it into the markup that gets sent to the user. I.e. this has no effect:
    function edit_preprocess_node(&$variables) {
      …
      $variables['attributes_array']['data-edit-entity-id'] = 'node/' . $node->nid;
      …
    }
    

    So, you'll need to make sure your template allows additional attributes to come through.

    It seems you're using Display Suite though, so maybe that's the culprit. Please let me know.

So, please clarify.

yannisc’s picture

It also happens on sites with no Display Suite installed.

yannisc’s picture

I don't know if there are other implications with this, but the following patch made Quick Edit to work:

--- /sites/all/modules/edit/js/edit.js
+++ (clipboard)
@@ -208,9 +208,11 @@
if (entityElement.length === 0) {
entityElement = $('.region-content').find(entityElementSelector);
}
- var entityInstanceID = entityElement
- .get(0)
- .getAttribute('data-edit-entity-instance-id');
+ if(typeof entityElement.get(0) != 'undefined'){
+ var entityInstanceID = entityElement
+ .get(0)
+ .getAttribute('data-edit-entity-instance-id');
+ }

// Early-return if metadata for this field is missing.
if (!metadata.has(fieldID)) {

loopduplicate’s picture

This happened to me because of a conflict with Zen.

Zen doesn't include the wrapper in its region template and the $classes string isn't rendered. ( https://drupal.org/node/1728134 ) Included in the $classes string is the class 'region-content'. The missing class seems to be causing the js error. See line 209 of edit.js:

$('.region-content').find(entityElementSelector);

since an element with the class doesn't exist, there is no method getAttribute as expected on line 213.

loopduplicate’s picture

Here's what I did to fix the error:

function exampletheme_preprocess_region(&$variables, $hook) {
  // Don't use Zen's region--no-wrapper.tpl.php template
  // @see https://drupal.org/node/1728134
  if (strpos($variables['region'], 'content') === 0) {
    $variables['theme_hook_suggestions'] = array_diff($variables['theme_hook_suggestions'], array('region__no_wrapper'));
  }
}

Cheers,
Jeff

wim leers’s picture

#2: I replied to your e-mail; the testing instructions you provided me longer work.

#4, #5: Thanks, that was tremendously useful! I've written an automated (though best-effort) status report requirement that checks whether the theme removes the "region-content" class, either by explicitly removing that class, or by removing the region wrapper altogether. I've also documented how to fix it in the README, pointing to your comments here.
That should help users in the future :)

I've done that at #2167981: Do a best-effort theme compatibility check in the status report.

wim leers’s picture

Status: Postponed (maintainer needs more info) » Fixed

So, #4/#5 have been addressed.

That leaves just #2. #2 has been answered in e-mail — yannisc had two problems:

  1. He has a custom filter for which he should define the filter type. Edit module can't do that, because it's a custom module, i.e. it doesn't live on d.o. If he publishes it on d.o, Edit can support it.
  2. He wanted in-place editing for Commerce Product entities, which will happen in #2168725: [META] Add support for in-place editing entity types other than Node.

So, with that, this support request has been answered!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.