1

When using Chrome console, I am editing the value of a variable that is set in the document ready event, but obviously this event has already fired and me editing the variable will have no effect.

Is there a way to re-run this event somehow?

loyalflow
  • 14,275
  • 27
  • 107
  • 168
  • Yea, save the edits in your JS, and re-load the page. – Cerbrus Feb 12 '14 at 15:40
  • the actual values are set server-side, so its dynamic values so I can't do that. – loyalflow Feb 12 '14 at 15:58
  • Is it possible to set a break point immediately after the variable is set, then change the value using the console, then continue execution of the code with the new value? That way, you wouldn't have to re-fire the event. – theyetiman Feb 12 '14 at 16:26

2 Answers2

2

Either edit your js files and refresh the page, or enter whatever you want to change into the console part of the Chrome Development Tools to see it without having to refresh the page

For e.g. $('p').hide();

Although you will obviously still need to edit your files to keep this change permanently.

user2798227
  • 853
  • 1
  • 16
  • 31
Sam Worley
  • 337
  • 2
  • 8
  • 1
    When you refresh the page, it is new request to server and js files will be again delivered to the browser in its original form (version without changes you made in Chrome dev tools), am I right? – foki Sep 16 '14 at 09:22
0

I'm not saying this is a good idea, as it's an event which is supposed to fire once when the DOM is ready, but have you tried this?

$().trigger('ready')

edit

scratch that - it won't work as jQuery gets rid of the event handler once it has run the first time.

See this question:

How to trigger $().ready() in jQuery?

So you'd probably have to rewrite all of your JS to fit into a separate function and then run that function again.

Having said that, the scope of the variable you are changing would need to be outside of that new function if it is going to retain the value you have changed it to.

Community
  • 1
  • 1
theyetiman
  • 8,514
  • 2
  • 32
  • 41