Skip to content

Commit

Permalink
class属性を要素にあわせて変更
Browse files Browse the repository at this point in the history
  • Loading branch information
imaz committed May 30, 2012
1 parent 97aca8e commit bdf9f3f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/views/attendances/index.html.haml
Expand Up @@ -19,24 +19,24 @@
%tr{:style=>'height:50px;'}
%td= calendar.school_day
- (1..6).each do |i|
%td.droppable{'data-calendar_id'=>calendar.id,'data-period'=>i}
%td.slot{'data-calendar_id'=>calendar.id,'data-period'=>i}
- attendance = calendar.attendances.select {|a| a.period == i }.first
- if attendance
%div.draggable{'data-id'=>attendance.id,:style=>'border:1px solid black;'}= attendance.subject.name
%div.chip{'data-id'=>attendance.id,:style=>'border:1px solid black;'}= attendance.subject.name
%br

:javascript
function Chip(){
this.id;
this.calendar_id;
this.period;
this.set = function(lesson){
this.id = lesson.find('.draggable').data('id');
this.calendar_id = lesson.data('calendar_id');
this.period = lesson.data('period');
this.set = function(slot){
this.id = slot.find('.chip').data('id');
this.calendar_id = slot.data('calendar_id');
this.period = slot.data('period');
};
this.drop = function(lesson){
this.set(lesson);
this.drop = function(slot){
this.set(slot);
$.ajax({
type: 'PUT',
url: '/attendances/'+this.id,
Expand All @@ -49,10 +49,10 @@
};
}
var chip = new Chip();
$('.draggable').draggable({
$('.chip').draggable({
helper:'clone'
});
$('.droppable').droppable({
$('.slot').droppable({
tolerance:'pointer',
drop:function(ev,ui){ui.draggable.appendTo(this);chip.drop($(this));}
});
Expand Down

0 comments on commit bdf9f3f

Please sign in to comment.