I'm creating a form which is dynamically populated depending on what location and date the user selects. I am currently looking at using either /base or a webservice to do this.
Here is a walkthrough of how I see it working
User selects location (a node in the content structure)
User selects a date
The location and date is sent to /base or webservice
The webservice checks the location and date, and returns the opening hours, which are a property of the location (using the Opening Hours project)
A dropdown list is populated with the opening times
I am more use to using webservices, but I don't know how to workout what location (node) is being passed - which I have managed to do using /base.
How would I iterate over the opening hours of a location in a /base class? Or is there another way of achieving what I am trying to achieve?
Decorate your base method with the following attribute
[RestExtensionMethod(returnXml = false)]
and create a helper class to convert whatever object you'd like to return to a json string. Find code snippet on from Sebastiaan's Contour contrib project
dynamic dropdown list from /base or webservice?
Here is the scenario
I'm creating a form which is dynamically populated depending on what location and date the user selects. I am currently looking at using either /base or a webservice to do this.
Here is a walkthrough of how I see it working
I am more use to using webservices, but I don't know how to workout what location (node) is being passed - which I have managed to do using /base.
How would I iterate over the opening hours of a location in a /base class? Or is there another way of achieving what I am trying to achieve?
Thanks in advance for any responses
Hi,
I'm pretty sure you can load the xml fragment that's stored when using the OpeningHours datatype on a document using
and from there on, use Linq to xml to get the xml elements you're after.
Hope this helps.
Regards,
/Dirk
Thanks Dirk, your reply worked perfectly!
I am using /base to handle the Ajax events, but it is returning HTML, as follows, rather than JSON
Below is the /base code
Any ideas why is returning HTML rather than JSON?
Decorate your base method with the following attribute
and create a helper class to convert whatever object you'd like to return to a json string. Find code snippet on from Sebastiaan's Contour contrib project
Don't forget to add references for Json.NET
Hope this helps.
Regards,
/Dirk
is working on a reply...