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
enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Lumpy posted:

This is why I started learning Backbone the other day.

How did a comparison between Angular and Ember spur you into learning Backbone? Just curious since I also started picking it up recently.

Adbot
ADBOT LOVES YOU

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!
Is there any way to adjust the bounding box of images/svgs to be non-rectangular? Right now, I have a bunch of pngs that look like triangles because of transparent backgrounds, but still have a rectangular bounding box. This is proving problematic because I want to put click events on these 'triangles', but since they have rectangular bounding boxes, when I click on one, it actually ends up hitting a nearby triangle instead of the one I want, since there is some overlap.

I've looked into setting the clip-path, but from what I've seen/tried, it's still a rectangular bounding box.

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Kekekela posted:

3) Consider Linux. I'm a lifelong Windows guy, but god its so much easier to use a lot of the command line based tools in Ubuntu.

After developing on a Mac for 2 years and being forced to recently switch back to Windows for my dev environment, I can't agree with this enough.

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Thermopyle posted:

It's so true that I do 100% of my development in an Ubuntu VM on my Windows machine. As a bonus, Its nice to be able to move my dev "machine" around very easily.

I'm doing .NET stuff now, and as far as I'm aware I'm under the impression that I should be using Visual Studio on Windows. If I'm wrong about this, please tell me because I'm looking for any excuse to use an actual terminal again :shepicide:

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!
I'm trying to attach an event handler to each of my Tile components in React. This is exactly how the docs say to do it, but I get "Uncaught TypeError: Cannot read property 'bind' of undefined" when I try this. What am I doing wrong?

code:
var TileList = React.createClass({
  handleClick: function(i) {
    console.log('You clicked: ' + this.props.tileData[i]);
  },
  render: function() {
    var tileData = shuffle(this.props.tileData);
    return (
      <ul className="tileList">
        {tileData.map(function(tile, i) {
          return (
            <Tile key={i} reactKey={tile.id} tileValue={tile.tileValue} tileColor={tile.tileColor} onClick={this.handleClick.bind(this, i)}></Tile>
          );
        }, *this*)}
      </ul>
    );
  }
});
Found it. I forgot to pass along *this* which I have now put into the original code.

Actually, I have a different problem now. The code runs, but nothing's happening when I click on a tile. I have some other click handlers that are on the Tile component which fire off just fine, but the one bound to the TileList isn't doing anything...

enthe0s fucked around with this message at 05:04 on Apr 19, 2015

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!
https://jsfiddle.net/69z2wepo/6685/

I left out some stuff I don't really think is relevant, but I can edit and include them if necessary.

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Lumpy posted:

You never set an onClick on your TileList, so no click on it is handled. I'm not sure if that's what you mean though. Also, I'm on my phone now so I might be missing something :v:

Your code seems very "un-React-like". There is a ton of logic in the tile, when it probably just wants to be a dumb view that calls whatever was passed to it as an onClick and that's it. The state of the game should live in a single place, so Tiles know nothing about it at all.

Yeah this is my first project with React, so it's very messy. I originally was going to have each Tile remember its state, but then I realized after going down that route that it doesn't make sense since I have to manage the state of 2 tiles to see if they are a match. So now I'm trying to get the TileList to manage the state with these click handlers.

I don't think I need to attach an onClick to the TileList itself. My thinking is that each Tile should have an onClick, which sends some info to the TileList so that it can manage the state of different Tiles. That's why I gave each Tile an onClick (line 50) and I thought that it would be handled by the onClick function defined on line 34. Isn't that what's happening in the example in the docs? https://facebook.github.io/react/tips/communicate-between-components.html

e: new page so here's the fiddle again so you don't have to go back and forth: https://jsfiddle.net/69z2wepo/6685/

Adbot
ADBOT LOVES YOU

enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Lumpy posted:

Gotcha. Here's a pared down version of your code where the Tile objects call their own _handleClick and check to see if they got something to call from their parent. If so, they call it, passing all their data back up: https://jsfiddle.net/69z2wepo/6789/

This makes so much sense now, Thanks!

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