0

Firstly my Jquery knowledge is very limited but am reading and practicing to remedy this, so please bear with me if this is a really basic question. As the title states i am getting a error message within my rails app

  $(".share a").button is not a function

My application.js file contains this

  $(function() {

  $(".share a")
  .button()
  .click(function() {

    var a = this;

    // first set the title of the dialog box to display the folder name
    $("#invitation_form").attr("title", "Share '" + $(a).attr("folder_name") + "' with others");

    // a hack to display the different folder names correctly
    $("#ui-dialog-title-invitation_form").text("Share '" + $(a).attr("folder_name") + "' with others");

    // then put the folder_id of the share link into the hidden field "folder_id" of the invite form
    $("#folder_id").val($(a).attr("folder_id"));

    // the dialog box customization
    $("#invitation_form").dialog({
      height: 300,
      width: 600,
      modal: true,
      buttons: {
        // first button
        "Share": function() {
          // get the url to post the data to
          var post_url = $("#invitation_form form").attr("action");

          // serialize the form data and post it the url with ajax
          $.post(post_url, $("#invitation_form form").serialize(), null, "script");

          return false;
        },
        // second button
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      },
      close: function() {
      }
    });

    return false;
  });

});

And my view page containds this to call the jquery ( I think)

  <div class="share">
        <%= link_to "Share", "#", :folder_id => folder.id, :folder_name =>       folder.nameunless @is_this_folder_being_shared %>
      </div>

Can anyone advise why I am getting this error as from what i can see it should be working, I.E. when i click a button labelled share I should get a popup window appear with my invitation form.

Any help appreciated as I am now stuck at this point

1 Answer 1

1

You most likely forgot to include jQuery UI.

Besides that, HTML does not have an attribute called folder_name (or folder_id). Please do not invent custom attributes - if you want to store custom data, use the data attributes: data-folder-name="whatever" and then use .data('folderName') to access it via jQuery.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the advice, though i do have the Jquery UI libary in my app. Would the attributes you have mentioned be causing an issue to prevent the popup working?
On second thoughts would it be that i have jquery-ui-1.8.9.custom.min.js and jquery-ui.js ( V 1.8.16) in the same directory?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.