This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <apex:page controller="ActionSupportParamDemoController"> | |
| <apex:form> | |
| <apex:repeat value="{!accounts}" var="account"> | |
| <apex:inputCheckbox value="{!account.IsActive__c}"> | |
| <apex:actionSupport event="onchange" | |
| action="{!handleAccountCheckboxChange}"> | |
| <apex:param id="account" name="accountId" value="{!account.Id}" | |
| assignTo="{!targetAccountId}"/> | |
| </apex:actionSupport> | |
| </apex:inputCheckbox> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub read_file { | |
| my $file_name = shift; | |
| print STDERR "READ $file_name ... "; | |
| my @file; | |
| open(FH, "< $file_name") or die("Can't read $file_name: $!\n"); | |
| while (<FH>) { | |
| chomp; | |
| my @t = split /\t/; | |
| @t = map { s/^\s+//g; s/\s+$//g; $_ } @t; | |
| push @file, \@t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.ds.tree.rbtree; | |
| import java.util.LinkedList; | |
| import java.util.Queue; | |
| import com.ds.tree.adt.BinarySearchTree; | |
| import com.ds.tree.adt.TreeTraversal; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <polymer-element name="django-ajax" extends="core-ajax"> | |
| <script> | |
| Polymer({ | |
| getCSRFCookie: function() { | |
| b = document.cookie.match('(^|;)\\s*csrftoken\\s*=\\s*([^;]+)'); | |
| return b ? b.pop() : ''; | |
| }, | |
| ready: function() { | |
| this.super(); | |
| this.headers = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //query | |
| $.ajax({ | |
| data: 'csrfmiddlewaretoken={{ csrf_token }}&..., | |
| type: 'post', | |
| }); | |
| //json | |
| $.ajax({ | |
| data: {'csrfmiddlewaretoken': '{{ csrf_token }}', ...}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #models.py | |
| class Task(models.Model): | |
| title = models.CharField(max_length=255) | |
| description = models.TextField() | |
| def __unicode__(self): | |
| return self.title | |
| #views.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def json_response(something): | |
| from django.utils import simplejson | |
| return HttpResponse(simplejson.dumps(something), | |
| content_type='application/json; charset=UTF-8') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| actions.get(action)(selected)代码写的不错,干净。 | |
| 源文件:https://github.com/marconi/django-quickstart/blob/master/src/todo/views.py | |
| ''' | |
| def home(request): | |
| todos=Todo.objects.order_by('-created') | |
| if request.method == 'POST': | |
| action = request.POST['action'].lower() | |
| todo_list_form = TodoListForm(data=request.POST, todos=todos) | |
| if todo_list_form.is_valid(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SearchView(FormMixin, ListView): | |
| template_name = 'search.html' | |
| context_object_name = 'spaces' | |
| form_class = SearchForm | |
| def get_initial(self): | |
| '''get initial values from request params''' | |
| if self.request.GET: | |
| initial = self.request.GET.dict() | |
| return initial |