Dan huwa post ieħor tiegħi serje għaddejjin dwar kif tuża jQuery ma SharePoint.
Jekk inti tixtieq titgħallem aktar dwar jQuery, I jirrakkomanda ħafna: jQuery fl-Azzjoni billi Bear Bibeault u Yehuda Katz.
UPDATE (diġà!): I ma think ta 'mod aħjar biex jillokalizza l- <TR> tag I tixtieq li jaħbu u kiteb dwar dan hawn. You may still find this article interesting anyway so I’m leavnig it up.
Irrid li jaħbu qasam tat-test, "Hide Me!"Kif muri:
Il jQuery ġej ma l-trick għalija:
<tip b'kitba ="text/javascript"> $(funzjoni() { $("Input[title = Hide Me!]").ġenitur().ġenitur().ġenitur().hide(); }); </iskrittura> |
Il-kodiċi huwa qal, "Issib lili oqsma kollha ta 'input li title = Hide Me!. Imbagħad, tikseb parent tagħha u mbagħad ġenitur li jmiss u l-* jmiss * ġenitur (phew!) u jinvokaw l-ġilda() metodu fuq li ħaġa, x'ikun dan jiġri jkun.
I dehret li l-istruttura ġenitur billi tiqies l-HTML għall-forma li SharePoint maħluqa kif muri:
<TR> <TD nowrap="true" valign="top" wisa="190px" klassi="ms-formlabel"> <H3 klassi="ms-standardheader"> <nobr>Hide Me!</nobr> </H3> </TD> <TD valign="top" klassi="ms-formbody" wisa="400px"> <!-- FieldName="Hide Me!" FieldInternalName="Hide_x0020_Me_x0021_" FieldType="SPFieldText" --> <medda inti="none"> <input isem="ctl00$m$g_bdb23c2c_fde7_495f_8676_69714a308d8e$ctl00$ctl04$ctl02$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" tip="text" maxlength="255" id="ctl00_m_g_bdb23c2c_fde7_495f_8676_69714a308d8e_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" titolu="Hide Me!" klassi="ms-long" /> <br> </medda> </TD> </TR> |
Din l-istampa turi l-istess, iżda markat-ġenituri:
L-ewwel ġenitur (1) is a span tag. Span’s parent (2) hija tag TD u mbagħad finalment irridu jiksbu l-ġenitur reali I tixtieq li jaħbu (3) li huwa l-tikketta TR innifsu.
This is a pretty terrible approach I think because it’s extremely dependent on the very specific structure of this form. When SharePoint 2010 toħroġ, this whole structure could change and break this approach. What I really want to do is craft a jQuery selector that is along the lines of “find me all the TR’s (u biss tags TR) li jkollhom x'imkien tfal elementi tagħhom f'qasam input li title = Hide Me!". I starting from the bottom and moving up. Assuming I figure this out, I ser post aġġornata malajr u faċli post "".
</aħħar>
Follow lili Twitter fi http://www.twitter.com/pagalvin
dak dwar dan l-approċċ għall-konstatazzjoni tal-tr ġenitur? Ewwel node fil-ġbir ta 'lymph antenat li huma elementi tr, li tirriżulta fil-tr ġenitur eqreb.
.ġenituri("tr:first")