Sammy.js does not get the location in Internet Explorer

631 views
Skip to first unread message

Yoann R.

unread,
Mar 21, 2013, 10:55:26 AM3/21/13
to sam...@googlegroups.com
Hi all,

I am cross posting that on stackoverflow, but it might be better suited here I think. 

Is there some explanation as when executing the following :

location.hash = "#/";

it works well in firefox (19.0.2) but not in IE (10.0.92).

In firefox it returns to the "homepage", whereas in IE it does nothing. No error shown either.

this code comes from this function :

self.addStoreItem = function () {
            var data = appFsMvc.utility.serializeObject( $("#StoreItemForm") );
            $.ajax({
                url: "/api/StoreItems",
                data: JSON.stringify( data ),
                type: "POST",
                dataType: "json",
                contentType: "application/json"
            })
            .done(function () {
                toastr.success( "You have successfully created a new StoreItem!", "Success!" );
                self.StoreItems.push(data);
                location.hash = "#/";
            })
            .fail(function () {
                toastr.error( "There was an error creating your new StoreItem", "<sad face>" );
            });
        };

and the code to manage sammy.js :

appFsMvc.App = function( StoreItemsViewModel ) {
        return $.sammy( "#content", function () {
            var self = this;

            this.use( Sammy.Cache );
            this.StoreItemViewModel = StoreItemsViewModel;

            this.renderTemplate = function ( html ) {
                self.$element().html( html );
                ko.applyBindings( self.StoreItemViewModel );
            };

            // display all StoreItems
            this.get( "#/", function() {
                this.render("/Templates/StoreItemDetail.htm", {}, function ( html ) {
                    self.renderTemplate( html );
                });
            });

            // display the create StoreItems view
            this.get( "#/create", function() {
                this.render("/Templates/StoreItemCreate.htm", {}, function ( html ) {
                    self.renderTemplate( html );
                });
            });
        });
    };

Developers tool of IE do not show any errors.

the console of firebuglite is giving me these hints :

  • when clicking on CreateNewItem

[Thu Mar 21 15:38:11 UTC+0100 2013] #content runRoute get /#/create

GET /Templates/StoreItemCreate.htm 200 OK 5ms

POST /api/StoreItems 200 OK 7ms

whereas doing the same in Firefox gives me :

[Thu Mar 21 2013 15:40:41 GMT+0100] #content runRoute get /#/create

GET http://myLocalHost:9501/Templates/StoreItemCreate.htm 200 OK 1ms

POST http://myLocalHost:9501/api/StoreItems 200 OK 27ms

[Thu Mar 21 2013 15:40:46 GMT+0100] #content runRoute get /#/

I can see in IE the url in the adress bar giving the correct url http://localhost:9501/#/create and then http://localhost:9501/#/ after posting my form. 

if you need some more code, just tell me. 

Thanks for reading,


Yoann 

Yoann R.

unread,
Mar 22, 2013, 5:39:38 AM3/22/13
to sam...@googlegroups.com
The library I used were :

sammy 0.7.1
jquery 1.7.2

then I tried upgrading to the latest :

sammy 0.7.4
jquery 1.9.1

it didn't work either:

I then moved back to the version used in the Json store :
sammy 0.6.2
jquery 1.4.2

And it did work modifying my ajax call to :

   $.ajax({
                url: "/api/Contacts",
                data: JSON.stringify(data),
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                success: function() {
                    self.contacts.push(data);
                    window.location.href = "#/";
                },
                error: function() {
                    
                }
            });

Has anyone else experienced the same ? I will try to post the whole code today.


2013/3/21 Yoann R. <arti...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Sammy.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sammyjs+u...@googlegroups.com.
To post to this group, send email to sam...@googlegroups.com.
Visit this group at http://groups.google.com/group/sammyjs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Giorgos Grispos

unread,
Mar 26, 2013, 12:52:04 PM3/26/13
to sam...@googlegroups.com
Hi Yoann,

I got the same problem with sammy and ie. Have you managed to find any solution on that? it seems that I have same problem even with ie9

cheers, Giorgos

Rajinikumar Ragupathy

unread,
Jan 28, 2014, 4:33:40 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
Hello I am getting same error, i attached my sample code


for example URL: www.mysite.com/#/index

var app = $.sammy(function() {
    this.get('#/index', function() {
        init();
    });
});

function int(){
    alert('testing');
}

In firefox and chrome i am getting alert message, but in IE its not working and i am not getting any error also. Any can one help for me?

harpreet bhatia

unread,
Jan 28, 2014, 4:35:47 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
try this
$(document).ready(function() {
var app = $.sammy(function() {

    this.get('#/index', function() {
        init();
    }); 
});
});


harpreet bhatia
Freelance Web Application developer
Technical reviewer (Codeigniter 2 cookbook)


-- sent from Ubuntu



--
You received this message because you are subscribed to the Google Groups "Sammy.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sammyjs+u...@googlegroups.com.
To post to this group, send email to sam...@googlegroups.com.

Rajinikumar Ragupathy

unread,
Jan 28, 2014, 5:02:35 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
Hello , 

I attached my sample code:

 (function($) {

        var app = $.sammy(function() {
            this.get('#/index', function() {
                init();
            });
        });

        function int(){
            alert('testing');
        }

        $(function() {
            app.run()
        });
    })(jQuery);
need to change anything? pls advise. its urgent

Harpreet Bhatia

unread,
Jan 28, 2014, 5:06:10 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
do something like

 $(document).ready(function() {
var app = $.sammy(function() { this.get('#/index', function() { init(); }); });

        $(function() {
            app.run()
        });
    });

Rajinikumar Ragupathy

unread,
Jan 28, 2014, 5:22:32 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
Hello Harpreet, 
Thanks for your reply.

I tried ur code and following code also, but no use, is there any way to solve this problem?

$( document ).ready(function() {
        alert('111111111');
        var app = $.sammy(function() {
                this.get('#/index', function() {
                        alert('222222');
                });
        });

        $(function() {
                app.run()
        });
});



Harpreet Bhatia

unread,
Jan 28, 2014, 5:26:07 AM1/28/14
to sam...@googlegroups.com, arti...@gmail.com
actually i dont have internet explorer. I am on linux. well you may try like
window.onload = function(){
 alert('111111111');
        var app = $.sammy(function() {
                this.get('#/index', function() {
                        alert('222222');
                });
        });

        $(function() {
                app.run()
        });
Reply all
Reply to author
Forward
0 new messages