Help with widgets

5
I was trying to do the advanced tutorial of creating widgets, the quicksearch one, while i ran into some trouble. For some unapparent reason it will not show the results. When i look into my FireBug it tells me that the query of getUsers is doing its job as i do get the right answer back, but for some reason it looks like it that showResults is never called? Did anyone else try the tutorial yet and encounter such a problem? The weird thing is that i did have it working at some point, ill try to figure out where things are going wrong in the mean time. Update 1: Thanks for the tips on how to debug the widget. It looks like i found the problem, when i use dojo.empty(this.inputNode) rather then dojo.empty(this.inputNode.innerHtml) it works. I am not sure about this, but it looked like it that when using the later version it kept on clearing the list and thus the list would not show any results. getUsers : function() { var inputString = mx.parser.escapeQuotesInString(this.inputNode.value); var xPathConstraint = "[contains(" + this.searchAttribute + ", '" + inputString + "')]"; mx.processor.getObjectsByXPath("//" + this.searchEntity + xPathConstraint, {}, dojo.hitch(this, this.showResults)); }, /* Display the search results in a list*/ showResults : function(objArray) { dojo.empty(this.listNode.innerHTML); for(var i = 0; i < objArray.length; i++) { var object = objArray[i]; var attribute = object.getAttribute(this.searchAttribute); this.listNode.appendChild(mendix.dom.li(attribute)); } if(objArray.length == 0) { this.listNode.appendChild(mendix.dom.li(this.txtNothingFound)); } }, /* init the search bar */ actSetupSearchBar : function() { this.buttonNode.value = this.txtSearch; this.connect(this.buttonNode, "onclick", dojo.hitch(this, this.getUsers)); }, uninitialize : function() { }
asked
1 answers
5

Hi Pieter,

great that you are already exploring this new area of possibilities! As for now, i cannot find any error in your code, so some trivial questions:

  • Did you try to place an "alert('showResults');" at the first line of the function?
  • Does firebug display any error messages in the Console tab?
  • Did you clear your cache? (ctrl + shift + delete in firefox)
  • Sometimes firebug stops working properly after a while (ignoring break points and such) in that case Firebug icon > options > reset all > restart firefox might help. (But that does not seem to be the case here)

If those suggestions do not help, you might post the complete code of this widget or send it to community@mendix.com.

Currently it is not possible to debug javascript using firebug in this beta build, but this will be fixed in the final release.

answered