1

I have made image gallery. And it works. But I maybe made a mistake that I can pay too much now :( I don't know.

I have a ImageGalleryController with Index action that returns IndexView with list of images.

When I navigate there browser URL is: localhost/mysite/gallery

When user click on image I made ajax call (with jquery). To action sethod ShowImage. ShowImageView contain full browser div with image in it. When I call show image I pass clicked imageID. After getting all needed data I return ShowImageView.

In ajax call on success I do:

$(document.body).append(resultViewShowImage);

And "ShowImageView" is displayed on top of my site. And here I can navigate images etc. It all works grat.

But now the huge problem:

When I display ShowImageView it is a div positioned on top of my site, and URL stay the same localhost/mysite/gallery, when I navigate images inside url is not changing.

I know that I made huge mistake here but what is the proper way to fix this. Can I do something with routing or maybe to display this "ShowImageView" in some other way (not appending it to body)?

I am trying to figure how 'flickr' display this top view but no luck :(

Abdul Munim
  • 18,869
  • 8
  • 52
  • 61
1110
  • 7,829
  • 55
  • 176
  • 334

1 Answers1

1

If you look at how flickr does it, and compare browsers, you see that they do not change the url in IE8 for example. I would change the url using JavaScript when the user switches pages, and use these changes to also work as parameters to your controller.

Edit:

Changing the url is only one part of the solution. For example: change the url to localhost/mysite/gallery/1 when the first image is shown, using JavaScript. This url would then point to the gallery controller with the number 1 as a parameter.

After that, in your controller, you have to see what the parameter is and based on that choose what image to display.

Community
  • 1
  • 1
Challe
  • 866
  • 12
  • 26
  • But is this only solution. Is it possible that for example g+ and facebook works the same way? If I give that url to another user then he can't directly navigate to this image with custom combined url... – 1110 Nov 19 '11 at 11:50