Project

General

Profile

Actions

Bug #2239

closed

On the group screen, when clicking on a node name, the popup with the node details appears with error

Added by Nicolas CHARLES almost 13 years ago. Updated almost 13 years ago.

Status:
Released
Priority:
1 (highest)
Category:
Web - Nodes & inventories
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
Name check:
Fix check:
Regression:

Description

When we click on the node name in the group page, the popup appears with the following error
Node with id undefined was not found

Error message was: Node with ID 'undefined' was not found

The log console doesn't show any error message

Actions #1

Updated by Nicolas CHARLES almost 13 years ago

An error also appears on the eventlog page when clicking on the details, it might be related

Actions #2

Updated by François ARMAND almost 13 years ago

This is due to the use of "prop" in place of "attr" in the following JS in SrvGrid.scala:

  def initJsCallBack(tableId:String, callback : (String) => JsCmd) : JsCmd = {
      JsRaw("""$('td[name="serverName"]', #table_var#.fnGetNodes() ).each( function () {
          $(this).click( function () {
              var aPos = #table_var#.fnGetPosition( this );
              var aData = jQuery(#table_var#.fnGetData( aPos[0] ));
              var node = jQuery(aData[aPos[1]]);
              var id = node.prop("serverid");
              var jsid = node.prop("jsuuid");
              var ajaxParam = jsid + "|" + id;
              %s;
          } );
        })
      """.format(....

This is following correction of issue #2036, so now I just don't understand when to use ".attr" and when to use ".prop".

Some information1 seems to say that "attr is what is defined on HTML, and .prop is for the DOM properties". But I thought that a prop was at least equals to attr, and seems that no.
Perhaps that is true only for specific attributes, like "serverid" or "jsuuid", which are not normalize, see this fiddle (with firebug opened) to see that: http://jsfiddle.net/fDcbS/

Nico, could you please try to understand that ? And perhaps change what have to be change in the commit ce6f985e92e8230ff9d58bbef082fdf47346eb85 ? Moreover, perhaps we should revert that commit ?

[1]
http://api.jquery.com/prop/ and http://api.jquery.com/attr/
http://forum.jquery.com/topic/whats-the-difference-between-jquery-attr-and-jquery-prop

The link from witch I initially read about "prefer .prop to .attr":
http://stackoverflow.com/questions/5874652/prop-vs-attr

Actions #3

Updated by Nicolas CHARLES almost 13 years ago

This is a very interesting topic :)

From these links :
http://stackoverflow.com/questions/5874652/prop-vs-attr
http://blog.jquery.com/2011/05/10/jquery-1-6-1-rc-1-released/

"The .prop() method should be used for boolean attributes/properties and for properties which do not exist in html (such as window.location). All other attributes (ones you can see in the html) can and should continue to be manipulated with the .attr() method."

So:
  • if you can read the attribute in the HTML, and it is unmutable, then it's an attr
  • if you cannot read the attribute in the HTML, then it's a prop
  • if you can read the attribute in the HTML, but it is mutable, then it has to be verified, but most of the time prop will be what you need (at least for checked, disabled and selected)

Note that if the value doesn't exist in the properties, you can set it with the prop, making it readable with a prop read afterward

Actions #4

Updated by François ARMAND almost 13 years ago

  • Status changed from New to In progress
  • Assignee set to François ARMAND
  • Priority changed from N/A to 1 (highest)
OK, so the next steps are:
  • not revert of 2036, as we need to be more careful on what is an attr/a prop
  • check for ALL .prop/.attr, and apply the rule established by Nicolas
  • sacrifice a chicken this night to summon the good will of JS Gods
Actions #5

Updated by François ARMAND almost 13 years ago

  • Status changed from In progress to Pending technical review
  • % Done changed from 0 to 100
Actions #6

Updated by François ARMAND almost 13 years ago

  • Assignee changed from François ARMAND to Nicolas CHARLES

Nicolas,

Could you please handle that technical review ?

Actions #7

Updated by Nicolas CHARLES almost 13 years ago

  • Status changed from Pending technical review to Released

The modification is consistent with the "rule", so it looks valid (we'll still have to check that the rule is valid)
Thank you Francois

Actions

Also available in: Atom PDF