Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
EdwardIII / admin.py
Created March 6, 2013 21:45
'OrderLineInline.fields' refers to field 'guests' that is missing from the form.
class OrderLineInline(admin.StackedInline):
model = OrderLine
readonly_fields = ('line_price',)
extra = 0
fields=('ticket','quantity', 'guests')
def guests(self, obj):
return obj.guest_set.join(', ')
class OrderAdmin(admin.ModelAdmin):
;(function ( $, window, document, undefined ) {
$.fn.labelForPlaceholder = function(){
return $(this).each(function(){
if(!$(this).hasClass('has-label-for-placeholder')){
$(this).keypress(function(){
if(!$(this).parents('.control-group').hasClass('has-had-keypress')){
$(this).parents('.control-group').addClass('has-had-keypress');
}
});
$(this).addClass('has-label-for-placeholder');
;(function ( $, window, document, undefined ) {
$.fn.labelForPlaceholder = function(){
return $(this).each(function(){
if(!$(this).hasClass('has-label-for-placeholder')){
$(this).keypress(function(){
if(!$(this).parents('.control-group').hasClass('has-had-keypress')){
$(this).parents('.control-group').addClass('has-had-keypress');
}
});
$(this).addClass('has-label-for-placeholder');
# i ran git pull master topic. This is how my branches look
master
* topic
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/topic
$.post($form.prop('action'), $form.serialize(), function(data){
var $booking_dialog = $('<div class="dialog-wrap">' + data + '</div>'); /* first instance needs to be wrappe
$dialog_header = $booking_dialog.find('.dialog-header');
$dialog_header.hide();
var $submit = $booking_dialog.find('input[type="submit"]');
var submit_text = $submit.prop('value');
$submit.hide();
if($booking_dialog.is(':data(dialog)')){
console.log('nope');
@EdwardIII
EdwardIII / f.html
Last active December 14, 2015 11:19
<script>
var TicketViewModel = function(tickets){ // must be ko-friendly tickets
var self = this;
self.tickets = tickets
this.next = function(){
// How can we let other views subscribe to this method?
console.log(JSON.stringify(ko.toJS(self.tickets)));
}
Array[2]
0: Object
desired_quantity: function d(){if(0<arguments.length){if(!d.equalityComparer||!d.equalityComparer(c,arguments[0]))d.H(),c=arguments[0],d.G();return this}b.r.Va(d);return c}
id: "1"
name: "Early Bird"
price: "5"
quantity: 10
resource_uri: "/api/v1/ticket/1/"
__proto__: Object
1: Object
Uncaught Error: Unable to parse bindings.
Message: ReferenceError: desired_quantity is not defined;
Bindings value: text: desired_quantity knockback-full-stack.min.js:104
the_event.fetch({success: function(){
var tickets = the_event.get('tickets');
var guestlist = new GuestList();
for(i=0; i<tickets.length; i++){
tickets[i]['desired_quantity'] = ko.observable(0);
guestlist.add(tickets[i]);
}
console.dir(tickets);
var viewModels = {
var GuestView = function(){
this.guestlist = ko.observableArray(ko.utils.arrayMap(tickets, function(ticket) {
return {
// How do i sync up guests and tickets, and ensure that when
// the num_of_guests increases, new guest input fields are created?
}))
}
var TicketView = function(){
this.tickets = ko.observableArray()