gpranav88-zz / clothzy-MVP

Clothzy MVP
0 stars 0 forks source link

Bug: Infinite loop in controllers #7

Closed agamdua closed 10 years ago

agamdua commented 10 years ago

I've been changing the directory structure and got a bug.

On the link localhost:3000/product/1, I'm getting into an infinite loop, where the productController is executing repeatedly, crashing the tab.

I'm pretty sure the problem is in is related to the routing, so it might be a good idea to check productcontroller.js and config.js to start with.

@hsinha - Is it possible that the change in directory structure is conflicting with the express API exposed? Personally, I don't think so, but you'll know better.

Branch: dirtybranch

Home page, localhost:3000 working fine => homepagecontroller.js is working fine.

Perhaps something with commonFactory.fetchID? That seems to be the only real difference.

@gpranav88 - wanna take a crack?


Obviously, there's a fallback, that'll be taken care of and working code is not too tough to pull up, but it would be cool if this could be sorted.

agamdua commented 10 years ago

@hsinha, @gpranav88 what is the partials folder for? The templates inside don't seem to be used for anything - or am I missing something?

agamdua commented 10 years ago

Adding a console.log shows that there is an object being returned in

$scope.productData

, though there is no data in it. Exact excerpt from productcontroller.js given below.

$scope.productData=commonFactory.productCRUD($resource).get({
                'id':commonFactory.fetchID($routeParams)
            });
            console.log($scope.productData)

Somewhere in the restructuring I must have broken the API/routes. Any idea where?

gpranav88-zz commented 10 years ago

The partials folder was same as the templates folder. I guess you can delete it.

On Fri, Jan 17, 2014 at 2:10 AM, Agam Dua notifications@github.com wrote:

@hsinha https://github.com/hsinha, @gpranav88https://github.com/gpranav88what is the partials folder for? The templates inside don't seem to be used for anything - or am I missing something?

— Reply to this email directly or view it on GitHubhttps://github.com/agamdua/clothzy/issues/7#issuecomment-32544596 .

agamdua commented 10 years ago

Cool will get rid of partials.

@hsinha, any luck? Let's have a phone chat tomorrow (if you've had time).

hsinha commented 10 years ago

@agamdua Any reason why you're loading JavaScript through AJAX ?

hsinha commented 10 years ago

@agamdua The controllers, services and even angular ki main library is being loaded via AJAX in the store and product pages !

agamdua commented 10 years ago

As discussed on the phone with @hsinha, going to try and debug by checking the stack traces. Apparently jquery is making the call (identified by him using the chrome dev tools initiator), although we haven't identified where the call is coming from.

Since I haven't used jQuery anywhere, and any extra implementation I've tried out is not pushed to Github, its crucial to check where the call is coming from.

Will update with progress. Will be running some things by Harsh (thanks for helping even though you have a Mojito on your plate!).

Otherwise will switch to one of the fallbacks discussed and get on with it.

agamdua commented 10 years ago

I think I've found our culprit. The fact that something in jQuery was causing the stuff to reload gave me a hint.

@hsinha, correct me if I'm wrong, but I think one needs to write a custom directive for integrating a jQuery plugin, which you didn't have to do since there was no plugin integrated yet.

Now however, the plugin nouislider has been added to the template.

On running this command I got the diff below:

    $ git diff --color cleanup-new-templates:./base.html dirtybranch:frontend/templates/base.html      

(cleanup-new-templates is a branch off master, that is, the code I received from Harsh without the changes I was making to the directory structure - I'll update link here once I push to Github)

Output:

-    <!-- Bootstrap core CSS -->
-    <link href="../static/css/bootstrap.css" rel="stylesheet">
-
-    <!-- Custom CSS for site -->
-    <link href="../static/css/clothzy.css" rel="stylesheet">
+  <link href="/static/css/bootstrap.css" rel="stylesheet">
+  <link href="/static/css/clothzy.css" rel="stylesheet">
+  <link rel="stylesheet" href="/static/css/iThing.css" type="text/css" />
+  <link rel="stylesheet" href="/static/css/jquery.nouislider.css" type="text/css">
+  <link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" rel="stylesheet">
+  <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
+  <!-- END OF CSS FILES-->

Screenshot: screen shot 2014-01-19 at 2 43 10 am

This is after checking everything is working on old templates with new fonts, images, etc.

Which basically means that I was on the last stage again trying to replace the old template with new (base.html from dirtybranch over master).

Hunch is that the home page would work, but the others wouldn't. @kartikdhar - can you confirm where you're using nouislider (which templates)? Sorry, I'm a bit sleepy and an answer in the AM would make it easier than going through the code again.

@hsinha - If anything here is incorrect, do feel free to let me know. Like I said earlier, any/all feedback always appreciated especially on code :)

agamdua commented 10 years ago

Closing this since I am now working on the fallback. Feel free to comment even after its closed in case anyone has any ideas.

agamdua commented 10 years ago

@kartikdhar - its definitely the plugin. Please refer #11