Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

I am trying to add this custom javascript and css code in a page

<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    $('.subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

 $('.download').click(function() {
     $(this).parent().next('table').slideToggle('fast').css('display', 'block');
    });
  </script>

<style>
    .subject {
      color: #009fdb;
      display: block;
      font-size: 20px;
      margin: -5px 0px 5px;
      width: 100%;
    }
    .files {
      display: none;
    }
  </style>

Every time i got this error

<section class="handouts">

        <h1>Frequently asked subjects</h1>
        <p class="subject">ACC311 - Fundamentals of Auditing </p>
        <table class="files" align="right">
          <tr>
            <td>PDF</td>
            <td>PPT</td>
          </tr>
        </table>
        
</section>

You need to be a member of Ning Creators Social Network to add comments!

Join Ning Creators Social Network

Email me when people reply –

Replies

  • Hello,

    I got it to work on my Ning 2 site by adding the code to the Custom Code box, rather than the Head box on the custom page.

    Also you don't need to load the jQuery library because Ning does that for us already.  Ning's version of jQuery uses x$ rather than just $ so making that change made the download button appear for me.

    I used this code in the Custom Code box:

    <script type="text/javascript" charset="utf-8">
        x$('.subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

     x$('.download').click(function() {
         x$(this).parent().next('table').slideToggle('fast').css('display', 'block');
        });
      </script>

    <style>
        .subject {
          color: #009fdb;
          display: block;
          font-size: 20px;
          margin: -5px 0px 5px;
          width: 100%;
        }
        .files {
          display: none;
        }
      </style>

    Try it out here: http://jqueryhelp.ning.com/page/test-download-button

    Best wishes!

    TJ

    • Hi TJ!

      I checked your page and the code is working like a charm. I use the same code on my page but i got the same error i mentioned above. I don't know why i am getting this error. But i figured out something that, when i try to put HTML tags in javascript code, the custom box gives error. When i put the button tag in javascript code like this button> instead of this <button> the custom box accept the code. But the download button does not appear sometime. I am sure you will resolve my problem.

      Regards

      • Hello Innocent, try it like this..  It sounds like you have something in the head with the class or id the same as what you have in your script..  ".subject"  So we will add user generated to your code. Hopefully this helps.  You have a great day.

        <script type="text/javascript" charset="utf-8">
            x$('DIV.xg_user_generated .subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

         x$('DIV.xg_user_generated .download').click(function() {
             x$(this).parent().next('table').slideToggle('fast').css('display', 'block');
            });
          </script>

        <style>
           DIV.xg_user_generated .subject {
              color: #009fdb;
              display: block;
              font-size: 20px;
              margin: -5px 0px 5px;
              width: 100%;
            }
           DIV.xg_user_generated .files {
              display: none;
            }
          </style>

        • Hi George!

          Thanks for your great help. I have tried your modified javascript, but unfortunately it's still not working. I tried many things but the only working thing is that I need to break the starting tag of the button (<button>)to(button>), otherwise the code does not accept by the custom box. But the broken tag create problems and does not work every time. I think the javascript is not accepted if it got any html tag. I also try to put <input type="button"> instead of <button> but i got the same error. :(

          • I'm sorry it didn't work. :-(

            If you can send me a link to the page your adding this code to and I'll see if I can figure out the problem, like TJ said it should be working. We should be able to just target the individual page you are working on and add the code to your NC custom code box..

  • Okay, this should do the trick. The code goes in your NC custom code box. All the JavaScript and CSS have been compiled into one JavaScript code.

    If you change THE PAGE to a different page just change the page name in the first line of the code. What's in there right now is     "test-download-button"

    <script type="text/javascript" charset="utf-8">
    x$(document).ready(function(){0<=document.URL.indexOf("test-download-button")&&(x$(".subject").append('<button class="download" style="float: right;">DOWNLOAD</button>'),
    x$(".subject").css({color:"#009fdb",display:"block","font-size":"20px",margin:"-5px 0px 5px",width:"100%"}),
    x$(".files").css({display:"none"}),
    x$(".download").click(function(){x$(this).parent().next("table").slideToggle("fast").css("display","block")}))});
    </script>

  • It might be better doing it this way. Just add this code where you added it originally for each individual page.

    <script src="http://bit.ly/2dnMxi8" type="text/javascript" charset="utf-8"></script>
    <style>
        .subject {
          color: #009fdb;
          display: block;
          font-size: 20px;
          margin: -5px 0px 5px;
          width: 100%;
        }
        .files {
          display: none;
        }
      </style>

    • Hi George!

      Thanks for putting your head in it. I tried your new script, but unfortunately I got the same error. Then I use the external file you mentioned above the script is loaded, but I think its not working can you please take a look at it.

      http://vuhelp.pk/page/test-download-button

      Thanks again. :)

      • I've noticed the HTML portion of your code is in the head of the network it should not be there. See image below.



        And in your custom code box you have a misplaced ending script tag, which can cause errors. I don't see any of the codes in this discussion including mine installed on your network, except the HTML that is in the HEAD of your network.

        Here's what it looks like now in your custom code box
        <!--
        <script type="text/javascript" src="//s.skimresources.com/js/39610X1024039X3634.adunit.js">
        -->
        </script>

        Move the ending script tag so it looks like this

        <!--
        <script type="text/javascript" src="//s.skimresources.com/js/39610X1024039X3634.adunit.js"></script>
        -->

        When you fix those two errors try the codes again and if it doesn't work let me know and I'll have another look.

This reply was deleted.

Search the Creators Network

Latest Activity

Kevin Acosta replied to Kevin Acosta's discussion Photo uploads being auto resized
"Well, even the FULL SIZE 38.5" x 36" poster that I attache was scaled down, so now that doesn't eve…"
50 minutes ago
Kyryl_Ning_Support replied to Aubrey Williams's discussion Paid Access 2017
"Hi there,
We plan to initially release the PaidAccess for Ning 3.0 with PayPal and credit card supp…"
8 hours ago
Kyryl_Ning_Support replied to Aubrey Williams's discussion Blank Space / Columns On Home Page
"Hi there!
Could you please share the screenshot with us and mark the blank spaces you are talking a…"
12 hours ago
Kyryl_Ning_Support replied to Naveen Jain's discussion Wiki like functionality in Ning
"Hi there!
Unfortunately, we don't have the module on our platform that would be working in the way…"
13 hours ago
Kyryl_Ning_Support replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Hi there!
Thanks for the question.
No, you don't have to create the new network each time the new f…"
13 hours ago
Matt replied to Aubrey Williams's discussion Paid Access 2017
"Good point, Stripe is awesome. "
13 hours ago
ASDKFljflkj is now a member of Ning Creators Social Network
13 hours ago
Alliance replied to Alliance's discussion Profile members on MY Page
"Thanks so much for this help things look sooooo much better now."
14 hours ago
Bizz ( John ) replied to Alliance's discussion Profile members on MY Page
"You could also try this which I have on my site just now for testing. This will adjust the avatar s…"
yesterday
Bizz ( John ) replied to Alliance's discussion Profile members on MY Page
"As matrix items are shared with other parts of the network if you add that then this would affect t…"
yesterday
Stanislav replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Hi, I'm waiting you to implement all new features to the Network in Q2 and want to start my network…"
yesterday
Alliance replied to Alliance's discussion Profile members on MY Page
"Thank you 
Right now I have a big space between each item. Following that same logic, the container…"
yesterday
Bizz ( John ) replied to Alliance's discussion Profile members on MY Page
"You can adjust the avatar sizes with this, just change the width to the size required.
.section-mem…"
Saturday
⚡JFarrow⌁ replied to Aubrey Williams's discussion Blank Space / Columns On Home Page
"You're welcome"
Saturday
Alliance replied to Alliance's discussion Profile members on MY Page
"I cant believe no one has this issue but me and have not solved this."
Saturday
George Swann replied to Naveen Jain's discussion Security error when accessing Ning network
"Everyone still has to wait until Ning updates their platform to be https/ssl compatible.  IMHO shou…"
Saturday
Aubrey Williams replied to Aubrey Williams's discussion Blank Space / Columns On Home Page
"Due diligence doesn't = nervous. Paid Access has not been a workaround for over three years because…"
Saturday
Naveen Jain replied to Aubrey Williams's discussion Paid Access 2017
"I just added stripe payment using formget.com."
Saturday
⚡JFarrow⌁ replied to Aubrey Williams's discussion Blank Space / Columns On Home Page
"Quite frankly you are nervous about the wrong things of what you say is true. Blank space can be re…"
Saturday
Aubrey Williams replied to Aubrey Williams's discussion Blank Space / Columns On Home Page
"I don't have a Ning network. I had one about eight years ago and I also remember the same blank spa…"
Saturday
More…