1

I've always been checking if there is server validation (or only client validation) by editing JS files of a site with Chrome DevTools.

This time I added an alert after clicking some button in IDE and saved the changes. The alert successfully shows up when I click some button. Then I opened on that site DevTools, went to sources, found a file called all_views.min.js (which is a file generated by Grunt from all JS views files). Ctrl+f+"alert" showed me the alert I just added. But when I added another alert after that and saved the JS file with ctrl+s I still get only 1 alert after clicking mentioned button.

What can be the cause of this? Yes, the JS file is generated but I have to generate it manually (and locally, not in browser) after changing a view script. So the browser shouldn't care.

I can't give you the whole script but here's the function I'm changing:

changeMap: function(a) {
    var b = this;
    $(this.el).find(".mapy-single-map").html("");
    var c = $(a.currentTarget).siblings(".btn-dark-blue")
      , d = $(a.currentTarget)
      , e = $(d).attr("map");
    alert(e), // alert added in the code
    alert("fdfgfdfd"), // alert added in DevTools
    this.collection.getDisplaysForMap(e).then(function() {
        b.renderPlayers(),
        $(d).removeClass("mapy-white-btn"),
        $(d).addClass("btn-dark-blue"),
        $(c).removeClass("btn-dark-blue"),
        $(c).addClass("mapy-white-btn"),
        $(b.el).find(".mapy-single-map").css("background-image", 'url("./graphics/mapy_ciemne/ciemne' + e + '.jpg")')
    })
},

And no, I wasn't editing the prettified version of all_views.min.js.

user1
  • 945
  • 2
  • 13
  • 37
  • Why are you ending your `alert` statements with commas? Isn't that invalid syntax? – Kayce Basques Mar 21 '17 at 18:18
  • @KayceBasques I tried using semicolons too, but that's what was generated by Grunt. In my JS views I have semicolons instead of commas. So I guess Grunt wouldn't convert them if it was a bad idea. Also, when I didn't add another alert but changed `alert(e)` to `alert("|"+e)` I had the same outcome - no change on the page. – user1 Mar 22 '17 at 10:29
  • Could be an issue with caching. Try clearing your browser cache and reloading the page. There's an option in dev tools to disable caching while dev tools is open. While dev tools is open you can also long click the refresh button in the browser and you will get a drop down with an option to clear the cache specifically for that tab and hard reload. – Gambit Mar 29 '17 at 16:55
  • which alert you are getting? – Sagar V Mar 30 '17 at 07:40
  • @Gambit I cleared all cache from the beginning in Chrome, went to the page, changed `alert(e)` to `alert(e+"|")`. Nothing happened. Long-clicked refersh button, chose "Empty cache and hard reload", changed JS in DevTools, saved JS, clicked a button. Alert didn't change. Went to DevTools's settings, set "disable cache on DevTools", refreshed the page, changed and saved alert in JS, clicked a button. Alert didn't change. – user1 Mar 30 '17 at 10:35
  • @SagarV I'm getting only the alert I wrote in code, not the temporary one added in DevTools. So I'm getting `alert(e)` but if I change it to `alert(e+"|")` I still get `alert(e)`. – user1 Mar 30 '17 at 10:36

1 Answers1

0

please look this: you can edit the javascrpit files dynamically in the Chrome debugger, under the Sources tab, however your changes will be lost if you refresh the page, to pause page loading before doing your changes

Community
  • 1
  • 1
croban
  • 387
  • 2
  • 7
  • I know. I am editing JS dynamically in DevTools, under the Sources tab. And I'm not refreshing the page. I know that because if I refreshed the page, the source would go back to the older version and it doesn't do that. But the webpage is still the same. – user1 Apr 05 '17 at 11:29
  • 1) load page 2) go to source set breakpoint (but somewhere where the the events are not attached, first line of init function or something like that) 3) refresh page and check if browser stop execution on your breakpoint , if yes change your javascript and continue js execution – croban Apr 06 '17 at 15:37
  • I think that chrome live editing ist not working as supposed. Because of that you have to stop loading javascript file at the first line of file or some init function (with breakpoint), than make you changes inside source code (save it), and than let browser load the file. – croban Apr 06 '17 at 16:13
  • I think i have the issue, because looks like the source tab looks cached, i have to reload and close dev tools, randomly to try to refresh the source code. I guess its a bug? – Miguel Oct 25 '17 at 10:51