Interesting... Dan, you're quite right that this works when using a link, but the reason it does is a bit unintuitive. What this basically comes down to is the fact that the browser sees the anchor on the URL and "understands" it, and then when MG calls <cflocation> to redirect to the target event, the anchor is maintained (at least in Firefox -- I didn't try any other browsers).
This means that if you wanted to do this from a link, you don't need to use append at all. From the previous example, you could just use: LINK: http://localhost/mgtest/index.cfm?event=Orange#fruity<http://localhost/mgtest/index.cfm?event=Orange&anchor=#fruity> RESULT XML: <result do="Fruitlicious" redirect="true" /> And this would work. I was honestly unaware that an anchor would be maintained after a <cflocation>, so I found this somewhat surprising. (Although it makes sense given that this is a client-side redirect.) If you want to redirect to an anchor programmatically, however, appending an event value in a result is definitely going to fail due to the URL encoding that is performed by MG internally when redirecting. -- Ezra On Tue, Jan 4, 2011 at 10:46 AM, Dan Wilson <[email protected]> wrote: > When I tested this locally, it worked. > > I did not set an event variable, rather I just added the #fruity to the > link manually. > > If you do this, and use the append attribute it will work and correctly > jump to the named link. > > Robert's test used an event variable, so perhaps in that mechanism there is > an issue, but if the url is drawn to the screen (rather > than programmatically added) it'll work. > > > DW > > On Tue, Jan 4, 2011 at 1:33 PM, Ezra Parker <[email protected]> wrote: > >> I'm afraid that the append attribute isn't going work -- as noted, it will >> add a name/value pair to the URL, and is also URL-encoding the hash. My >> suggestion would be to use the event.forward() method in your controller >> instead of a result, as the forward() method has an optional anchor argument >> that you can use: >> >> >> http://docs.model-glue.com/wiki/ReferenceMaterials/EventApi#ForwardeventName:stringappend:listpreserveState:booleananchor:stringaddToken:boolean >> >> So something like this should do the trick: >> >> <cfset arguments.event.forward( eventName="someevent", anchor="someanchor" >> ) /> >> >> Also, if you want to maintain the auto-documenting nature of your MG XML >> config, you can pass in the target of the redirect and the anchor name as >> arguments like so: >> >> <message name="redirectToAnchor"> >> <argument name="redirectEvent" value="someevent" /> >> <argument name="redirectAnchor" value="someanchor" /> >> </message> >> >> And then in your message-listener function you can do: >> >> <cfset var redirectEvent = arguments.event.getArgument( "redirectEvent" ) >> /> >> <cfset var redirectAnchor = arguments.event.getArgument( "redirectAnchor" >> ) /> >> >> <cfset arguments.event.forward( eventName=redirectEvent, >> anchor=redirectAnchor ) /> >> >> HTH, >> >> -- >> Ezra >> >> >> >> On Tue, Jan 4, 2011 at 7:28 AM, Sir Rawlins < >> [email protected]> wrote: >> >>> quite how 'happy new year' came out of my fingers as 'happy you new' >>> is beyond me.... more coffee? >>> >>> On Jan 4, 3:26 pm, Sir Rawlins <[email protected]> >>> wrote: >>> > Haha ... Happy you new, you bastards! ;-) >>> > >>> > Thanks for the tip Dan. I've just given it a shot but it doesn't >>> > appear to be playing ball, perhaps I'm missing something. I'm setting >>> > the variable into the event like this: >>> > >>> > <cfset ARGUMENTS.event.setValue("Anchor", "##item_table") /> >>> > >>> > However when it's appended to the URL it comes out like this: >>> > >>> > &Anchor=%23item_table >>> > >>> > Any ideas what might be causing it to format it in that manor? >>> > >>> > Thanks mate, >>> > >>> > Robert >>> > >>> > On Jan 4, 3:21 pm, Jim Priest <[email protected]> wrote: >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > > FWIW - I just updated the docs with Dan's example. >>> > >>> > > Jim >>> > >>> > > On Tue, Jan 4, 2011 at 10:07 AM, Dan Wilson <[email protected]> >>> wrote: >>> > > > You can do this by adding a variable into the event, then using the >>> append >>> > > > attribute of the result. This will stick the value of the event >>> variable in >>> > > > the URL. >>> >>> -- >>> Model-Glue Sites: >>> Home Page: http://www.model-glue.com >>> Documentation: http://docs.model-glue.com >>> Bug Tracker: http://bugs.model-glue.com >>> Blog: http://www.model-glue.com/blog >>> >>> You received this message because you are subscribed to the Google >>> Groups "model-glue" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected]<model-glue%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/model-glue?hl=en >>> >> >> -- >> Model-Glue Sites: >> Home Page: http://www.model-glue.com >> Documentation: http://docs.model-glue.com >> Bug Tracker: http://bugs.model-glue.com >> Blog: http://www.model-glue.com/blog >> >> You received this message because you are subscribed to the Google >> Groups "model-glue" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected]<model-glue%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/model-glue?hl=en >> > > > > -- > Plutarch - "The mind is not a vessel to be filled but a fire to be > kindled." > > -- > Model-Glue Sites: > Home Page: http://www.model-glue.com > Documentation: http://docs.model-glue.com > Bug Tracker: http://bugs.model-glue.com > Blog: http://www.model-glue.com/blog > > You received this message because you are subscribed to the Google > Groups "model-glue" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<model-glue%[email protected]> > For more options, visit this group at > http://groups.google.com/group/model-glue?hl=en > -- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
