Question: I'm not really sure how best to explain what I want, so I'll just show some code:

```
class Stuffclass():
    def add(self, x, y):
        return x + y

    def subtract(self, x, y):
        return x - y

    # imagine that there are 20-30 other methods in here (lol)

class MyClass:
    def __init__(self):
        self.st = Stuffclass()

    def doSomething(self):
        return self.st.add(1, 2)

m = MyClass()
m.doSomething() # will print 3
# Now, what I want to be able to do is:
print m.add(2, 3) # directly access the "add" method of MyClass.st
print m.subtract(10, 5) # directly access the "subtract" method of MyClass.st
m.SomeMethod() # execute function MyClass.st.SomeMethod

```

I know I could do something like this:

```
class MyClass:
    def __init__(self):
        self.st = Stuffclass()
        self.add = self.st.add
        self.subtract = self.st.subtract

```

...but this requires manually assigning all possible attributes. 

I'm writing all the classes so I can guarantee no name collisions.

Making MyClass a subclass of Stuffclass won't work, because I actually am using this in a plugin-based application, where MyClass loads other code dynamically using **import**. This means MyClass can't subclass from the plugin, because the plugin could be anything that follows my API.

Advice please?

Answer: 
This should work

```
$('.quantity').click(function() {
    var that = this;        

    $.post('quantity.php', { quantityId: $(that).attr('id') }, function(data) {
        $(that).html(data);
    }); 
}); 

```

But this is how i'd write it

```
<div class="quantity" data-id='<?=$unique_id?>'>
    Quantity
</div>

$('.quantity').on('click', function() {
    var that = this;        

    $.post('quantity.php', { quantityId: $(that).data('id') }, function(data) {
        $(that).html(data);
    }); 
});     

```

And for dynamic divs

```
<div class="quantity" data-id='<?=$unique_id?>'>
    Quantity
</div>

$(document).on('click', '.quantity', function() {
    var that = this;        

    $.post('quantity.php', { quantityId: $(that).data('id') }, function(data) {
        $(that).html(data);
    }); 
});     

```
The `onclick` binding to your div won't work once the div has been refreshed (it binded on document.ready() right?). The solution will be either to rebind the function to your element every time you change it (a bad one) or use the `on()` function of `jquery`. Example code:

```
$(document).on('click', '.quantity', function(){
    var id = $(this).attr('id');        

    $.post('quantity.php', { quantityId: id }, function(data){
        $('#'+ id).html(data);
    }); 
}); 

```

**UPDATE:** As discussed in comments, the `on` method should bind to the document as a whole and not the the class to actually work as the deprecated `live()` method.