Txoj kev sai thiab yooj yim: Siv jQuery teev A ntawv teb tus nqi rau ntawm daim ntawv SharePoint

Kuv pib ua si ib ncig nrog jQuery nag hmo. Kuv twb tau xav ua li no kom ntev, ever vim Paul Grenier pib sau nws series hais txog jQuery rau cov neeg siv cov kev xaus ntawm qhov venerable www.endusersharepoint.com qhov Web site. Raws li kuv siv nws, Kuv cia siab ntxiv hauv "Ceev thiab yooj yim" zoo li no tuaj posts. Tsev xa no piav tau paub ntawv teb tus nqi rau tej yam koj xav li cas.

Hauv no scenario, Kuv tau tsim ib daim ntawv teev kev cai uas tus "tshiab" daim ntawv zoo li:

image

Qhov no yog daim tshiab rau ib daim ntawv teev kev cai nrog rau lub neej ntawd Title sab thiab ob daim ntawv teev txhua (tsis kawm ntawv txhua; Kuv tsis xav tias nws yuav tsum xyuas txhua qhov sib txawv).

Lub hom phiaj yog mus cob ib tus nqi uas arbitrary rau tom daim teb, "DefaultMeFieldNoSpaces" (koj yuav paub kuv yog ib tug coward nrog cov khoom mus "tej qhov tsis muaj chaw" me ntsis, tab sis kuv spice nws kawg ntawm qhov tsab xov xwm no).

JQuery ua haujlwm rau kuv no me ntsis:

<Script yam ="ntawv nyeem/javascript">

  $(muaj nuj nqi() {

    $(' input[Title = DefaultMeFieldNoSpaces]').attr(
        {tus nqi: ' Koj yog ib tug tshawb txog ntawm daim zajlus twisty, xwm yeem xwb.'});

  });

</tsab ntawv>

Raws li kuv nkag siab hais tias jQuery no me ntsis yog tias, "nrhiav kuv tej tswv yim tag nws txoj kev cai title = DefaultMeFieldNoSpaces. Ces, teev tas nrho txog lawv qhov tseem ceeb rau ib kab lus uas muaj koob npe los ntawm ib lub computer qhov qub."

Vim yuav tsuas muaj ib daim teb nyob rau hauv daim ntawv uas muaj title sib npaug zos rau cov "DefaultMeFieldNoSpaces" peb yog cov assured uas muab ib tug nqi rau ntawd daim teb thiab lwm yam tsis muaj.

Dab tsi txog nws lub npe muaj tej qhov chaw nws nyob hauv teb? Nws tseem yuav luag sib npaug:

<Script yam ="ntawv nyeem/javascript">

  $(muaj nuj nqi() {
     $(' input[Title = cob teb muaj chaw]').attr(
        {tus nqi: ' Koj yog ib tug tshawb txog ntawm daim zajlus twisty, xwm yeem xwb.'});

  });

</tsab ntawv>

Kuv xav tias qhov no yog ib tug zoo haum mus kom ze, peb qab hau tias peb yuav tsum tau nrhiav teb tias peb xav thiab lub teb xwb xav. Yog koj saib cov HTML SharePoint yog muab rau peb, nws puas tsawm tsawv thiab ntxhov:

<tswv yim
lub npe= "ctl00$ m$ g_bdb23c2c_fde7_495f_8676_69714a308d8e$ ctl00$ ctl04$ ctl02$ ctl00$ ctl00$ ctl04$ ctl00$ ctl00$ TextField"
hom= "ntawv nyeem"
maxlength= "255"
tus ID= "ctl00_m_g_bdb23c2c_fde7_495f_8676_69714a308d8e_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
npe= "DefaultMeFieldNoSpaces"
hoob= "ms-ntev"
/>

"title" stands raws li ib tug coj los thiab cim hopefully attribute yuav pab peb xyuas seb tej sab uas peb xav mus cob peb tus nqi uas arbitrary.

Qhov no yog ib cov tswvyim foundational. Teev ib daim teb nyob rau hauv ib txoj kev arbitrary li no tsis yog yuav los yeej muaj khoom plig. Txawm li cas los, Yog tias peb xav kom ua li nthuav daim ntawv theem khoom (twg tagnrho uas peb ib txwm xav ua, tau mas, tom qab peb tas ntxuav tais diav), li hloov tau tus nqi ntawm "teb b" txiav raws tus nqi ntawm "teb ib", peb (KUV) yuav tau paub tej no.

Kuv xav tias peb zoo sij hawm kom tau ib pab real nqi nov yog ntawm lub npe, kawg rau ntawv teb. Muaj tej zaum yuav zoo dua, kev txhim khu ntau kev qha. Yog kuv nrhiav tau, Kuv mam li hloov no ncej. Yog koj paub ib txoj kev zoo, thov cia ib tug saib.</kawg>

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Ntawv cim npe Technorati: ,

5 xav txog"Txoj kev sai thiab yooj yim: Siv jQuery teev A ntawv teb tus nqi rau ntawm daim ntawv SharePoint

  1. Paul Galvin

    Oskar, Kuv tsis muaj ib tug mus kom ze tsis tau li vim tias kuv muaj tsuas nyuam qhuav pib siv nws mus ncig ua si. Raws li kuv siv nyob rau hauv ib cheeb tsam ntau lawm kuv mas nws yeej yuav pib sau hais txog kuv qhov kev.

    Tsaug rau qhov link no mus spjqueryfield.

    Teb
  2. Oskar Austegard

    Paul, koj mus kom ze txhaj cov javascript rau qhov edit phab ntawv yog dab tsi? Ua li ntawd rau ib deployable, yam yooj yooj yim yog lo qhia lub ntsis, raws li kuv txhawj. Koj yeej tsis tau tsim ib daim ntawv kev cai txhua lub sij hawm… Kuv xav tias qhov no, http://spjqueryfield.codeplex.com/ , yog lub caij pib zoo. Deploy ib zaug, rov qab siv ces lub ntxiv…

    Teb

sau ntawv cia

Koj email chaw nyob yuav tsis muab luam tawm. Search cim *