1

After I could solve the namespace problem between jQuery and Prototype, with the help of the friendly community here I have another problem to integrate the Svg Edit(or) into Magento. Now I get a new error message in firebug: btn.attr("title") is undefined although the variable has multiple return values and I can't see why this isn't working. The error occurs on line 4137 in the svg-editor.js file. Any help would be great. Thanks in advance!

Line 4137:

var new_title = btn.attr('title').split('[')[0] + '[' + keyval + ']';

Edit:

Thats what i get back. Maybe it's the last value which generates the error?:

alert(btn.attr('title'));

// Select Tool [1]
// Pencil Tool [2]
// Line Tool [3]
// Rectangle
// Square
// Ellipse
// Circle
// Path Tool [7]
// Text Tool [6]
// Image Tool [8]
// Zoom Tool [Ctrl+Up/Down]
// undefined

After changeing the code to @epascarello 's proposal i get more values back than before. It seems that there are some menu-items missing:

alert(btn.prop('title'));

  // ...
  // undefined
  // undefined
  // Edit Source [U]
  // Wireframe Mode [F]
  // undefined
  // Delete Element [Delete/Backspace]
  // Move to Top [Shift+Up]
  // Move to Bottom [Shift+Down]
  // Undo [Z]
  // Redo [Y]
  // Clone Element [C]
  // Group Elements [G]
  // undefined
Community
  • 1
  • 1
ThreeCheeseHigh
  • 1,429
  • 5
  • 22
  • 40

2 Answers2

1

Keep to attr, but check it's defined. Skip it if it's not:

if(opts.sel && !opts.hidekey && btn.attr('title')) {
  var new_title = btn.attr('title').split('[')[0] + '[' + keyval + ']';
  ...
0

Use prop() instead of attr()

var btn = $("#myButton");
btn.prop("title");
epascarello
  • 204,599
  • 20
  • 195
  • 236
  • Thanks for reply! I've tried your code: `var somevar = btn.prop("title"); var new_title = somevar.split('[')[0] + '[' + keyval + ']';` and it seems that there are more values than i get by the alert() function above. I'll add this to the post. – ThreeCheeseHigh Aug 23 '11 at 11:30