Haraka na Easy: Kujenga jQuery yako mwenyewe Sandbox kwa SharePoint

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

Kupata ilianza na jQuery katika SharePoint ni ya kushangaza rahisi (kwangu). (I do have serious questions about a “best practices” approach to deploying these things to production, but that’s for another day). I’ve just started playing with this technology and to that end, I created a sandbox environment to use. If you’re looking to get started with jQuery, you may find this approach useful.

1. Create a Blank Site

Create a blank site somewhere in your site and call it something clever like “jQuery Sandbox”.

2. Download jQuery

You can download the jQuery javascript library from here: http://docs.jquery.com/Downloading_jQuery

Save that to to your desktop.

I have been using the “minified” version.

3. Create a SharePoint Document Library

In your sandbox site, create a document library.

4. Upload the jQuery Library to SharePoint

Access the doc library you just created and upload the jQuery library.

5. Create a Custom SharePoint List

I’ve started with a custom list because I want to muck about with standard SharePoint forms. You could also create a page in a pages library or web part pages and probably a lot of other places.

Add some columns to the custom list so that you have something to run jQuery against. My initial objectives were to:

  1. Hide a field.
  2. Assign a value to a field.

With that objective in mind, I added two text fields. Over time, I’ll be playing with links, images, lookups, nk.

6. Modify the NewForm.aspx Web Part Page and Add a Content Editor Web Part

This is a little black magic-ish , in that it’s a new concept to me. I first learned about this from Paulo Grenier, SharePoint jQuery Superstar, saa CodePlex yake tovuti ya mradi: http://spff.codeplex.com/.

Fuata hatua hizi ili kuongeza CEWP kwa ukurasa huo huo kwamba inaonyesha NewForm.aspx kwa orodha yoyote desturi:

  1. Kupata orodha ya desturi na bonyeza Mpya.
  2. Append zifuatazo URL: PageView = Shared&ToolPaneView = 2

Ambayo kubadilisha data yako boring vanilla kuingia fomu kutoka kwa kitu kama hiki:

image

Kwa hili:

image

Kuongeza mhariri maudhui ya mtandao sehemu ya ukurasa.

7. Kuandika jQuery wako kwanza Kanuni

Kufungua kwamba CEWP katika mtazamo wa kanuni na kuongeza yafuatayo:

image

Hapa ni kanuni halisi kama unataka nakala / kuweka:

<script
    "text/javascript"
    src ="../../jQuery Library/jquery-1.3.2.min.js">
</script>

<script aina ="text/javascript">
  $(kazi() {

    $('# ResultsID').html('Kuna' + $('A').ukubwa() + 'Vitambulisho vitambulisho kwenye ukurasa huu.');

  });
</script>

Kusababisha:
<div id ='ResultsID'></div>
/kusababisha

Note that the first <script> tag is referencing the actual jQuery library. Presumably, these things change over time, so you’ll want to make sure you a) use the right name and b) point it to the correct SharePoint document library.

Bask in the Glory

If you did it correctly, you’ll see a result similar to the following:

image

Wrapping Up

This isn’t the only way to get started, but it’s quick, easy and isolated from your existing SharePoint environment.

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

2 mawazo juu ya "Haraka na Easy: Kujenga jQuery yako mwenyewe Sandbox kwa SharePoint

  1. sujith krish

    Umegundua kuwa kuongeza CEWP katika editform.aspx kunaweza kuvunja ukurasa na sehemu ya maelezo ya toleo itaonekana kwenye kiolesura? Marekebisho yoyote kwa hii?

    Yeyote ?

    Kujibu

Kuondoka Reply

Anwani yako si kuchapishwa. Mashamba required ni alama *