Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

FIS Day35

  • Goal:
    • if there is a no bounty div
    • dont just render the TR for that bounty
    • rather render the entire bounty table for that issue and insert that
1
2
3
4
5
6
7
8
9
10
//the [0] is to make sure the element has something in it
//it is the equivalent to a .exists? method
 if ($("#bounties_table")[0]){
//this adds the tr object defined in the controller
    $('#bounties_table tbody').prepend("<%= j render(@bounty) %>");
  } else {
//replace with requires that you pass in the HTML-- not a selector
    $("#no_bounty").replaceWith("<%= j render 'bounties/bounties_table', :issue => @bounty.issue %>")
//the j escape is necessary to render the html
  }

Comparing the inputs….

Pulling out values for two different forms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  $('button#pledge').live(
    "click", (function() {
    pageValue = $('#bounty_price_page').val();
    modalValue(pageValue);
  }));

  function modalValue(pageValue) {
    $('#create-bounty').live(
    "click", (function(event) {
    modal = $('#bounty_price').val();

    if(parseInt(modal)!=parseInt(pageValue)){
      event.preventDefault();
      $('span#error').replaceWith('<span class="label label-important">Please Enter The Same Value</span>');
    }
  }));
}

Comments