Announcement

Collapse
No announcement yet.

Instantiate an object from javascript to call a method....

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Instantiate an object from javascript to call a method....

    Hi,
    • Bridge.NET 17.7.0
    • I have TripSeekerSearch.Engine project which is a Bridge.NET project and a class SearchInput
    Click image for larger version

Name:	1.png
Views:	1
Size:	38.7 KB
ID:	6085

    I am trying to instantiate the SearchInput class from within JS as I have a method Search():
     
     public class TripSearchEngine {     public static SearchOutput Search(SearchInput aSearchParameters)     {         var searchEngine = new SearchEngine(Trips());          return searchEngine.Search(aSearchParameters);     } }
    that takes a parameter of that type with the following:
     
     var seachInput = new TripSeekerSearch.Engine.Framework.Search.Dtos.SearchInput();
    but am getting undefined:
    Click image for larger version

Name:	2.png
Views:	1
Size:	10.6 KB
ID:	6086
    The namespace is correct and I have had a look at https://deck.net/405118c4961642fd5e5623fb357e51abwhich indicates that this should be easily possible.

    What have I missed? How do I make this work?

    #2
    Your code looks correct. By changing the namespace of your sample, I was able to call the full classpath.

    https://deck.net/001b467a6369def6ab5816405d00e3f3

    In the screen capture of Chome dev tools that you provided, your js call did not fail, it just did not write anything to the console. What you see is the default functionality of Chrome dev tools and is the expected result.

    In the browser developer tools, on the next line after declaring var seachInput, add console.log(seachInput) to output the object you defined above to the console. The following should work:

    var test = new TripSeekerSearch.Engine.Framework.Search.Dtos.SearchInput();
    console.log(test);
    Hope this helps.

    Comment


      #3
      Doh!!! Thanks geoffrey.mcgill. It did work exactly as you described. I was too hasty with the undefined.

      Comment

      Working...
      X