Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
KoRMaK
Jul 31, 2012



This feels like a really stupid question but I cant figure out what the transom I have to bridge is: I have a webpack that has sortablejs in it, and I'd like to be able to call sortablejs from the browser's dev tools console, just like i could when I was using jquery, so I can interactively play around with it. how do I do that? my full tech stack is rails and yarn based

Adbot
ADBOT LOVES YOU

KoRMaK
Jul 31, 2012



necrotic posted:


The hacky stupid approach I will suggest is to do a window.sortablejs = require (…) somewhere in your sources to make the package available to the console.
debugging.
perfect! this makes a lot of sense. thank you!

code:
// app/javascript/packs/application.js
import Sortable from 'sortablejs';

window.sortablejs = Sortable

// dev tools console
sortablejs.get(demo1).toArray()
(5) ['3v8', '3ve', '4f9', '4g8', '44p']

KoRMaK
Jul 31, 2012



Ima Computer posted:

Alternative method: set a breakpoint in your JS code in a place where where that package is available. When the debugger hits the breakpoint and JS execution is paused, your console will have access to all variables in scope for the currently executing code.
Yes I had considered this but since you are at a breakpoint time is frozen and you can't interact with the rendered browser ui as you normally would.

KoRMaK
Jul 31, 2012



that's a very neat trick and has managed to dispell a lot of mystery around using node modules in my project that i just hadn't given a poo poo to dive into. now i understand how to grow another piece of my infra.


soooo long inline javascript

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply