Search code examples
javascriptpolymerpolymer-1.0

IF condition using string


I am programming in Polymer 1.0 and am trying to create an IF function to change the value of a property. My function is the following:

_searchButton: function(selectednamedropdown, selectedtypedropdown){
  if (selectednamedropdown=="no_name_selected" && selectedtypedropdown=="no_type_selected"){
    this.searchUsagesBtn = true
  } else{
    this.searchUsagesBtn = false
  }
}

In my mind when selectednamedropdown is equal to "no_name_selected" and selectedtypedropdown is equal to "no_type_selected" the function should set searchUsagesBtn to true and when they are not these values, false.

However, the function does not ever seem to be returning true even when these conditions are met. Any ideas why this might be? Thanks for all help


Solution

  • The issue was around how JavaScript treats properties within functions. The function was storing the new value and old value of the first property and not any values of the second property. The solution involved making 2 functions to test the strings in each property. Thanks for all assistance