Endlessly jbejtu <div> Tags u jQuery

Din tidher qisha tali suġġett oddball, M'inix ċert li huwa verament jiswa blogging dwar, iżda li qatt ma waqfet lili qabel, hekk here we go Tbissem

Jien jaħdmu fuq proġett fejn jien ġbid xi data minn tfittxija, packaging it up into an XML message and then that XML is ultimately transformed into HTML via XSLT.  There’s a lot of jQuery involved, one bit of which implements some tabbing functionality.  When you click on a tab (verament, a <div>), jQuery invokes .hide() and .show() on various divs (the initial page load downloads all the content so there are no postbacks in this case).

A bunch of hours ago, the tab switching logic started to behave erratically and it wouldn’t show one of my tabs.  I ultimately tracked it down to the fact that internet explorer (inqas) thought that the <div> tags nested far, far deeper than intended.The developer toolbar would show:

-<div id=”Tab1Content”>
  -<div>
    -<div>
      -<div id=”Tab2Content”>
        -<div>
           …………………………
                   </div>  <—finally showing it was closed all the way down here!

Allura, if I did a $(“#Tab1Content”).hide(), I’d also hide Tab2 and I could never show Tab2 if I didn’t also show Tab1.  I copied and pasted the code up into visual studio and it showed all of the div’s lining up nicely, just like they were supposed to be doing, looking like this:

-<div id=”Tab1Content”>
  +<div>
  +<div>
-<div id=”Tab2Content”>
  +<div>
  +<div>

I beat my head against the wall for a while and noticed that in the actual HTML code was generating a lot of empty <div> tags, like:

<korp>

  <div id=”Tab1Content”>

    <div id=”row1” />
    <div id=”row2” />

  </div>

  <div id=”Tab2Content”>

    <div id=”row1” />
    <div id=”row2” />

  </div>

</korp>

(The above is waaaaaaaaaaaay oversimplified.  The empty div tags are totally valid. Some of my <div> tags were full of content, but many more were not.  I came to the realization that my <XSL:għal-kull> directives were emitting the short-form div tags when the xsl:for-each didn’t’ find any data.  I forced an HTML comment into the output, kif muri:

image

 

After I did that, all the div’s lined up nicely and my tab switching started working.

As always, I hope this helps someone in a pinch.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Quick jiffissaw: "L-isem tip kontenut" $ Riżorsi:ReportServerResources … ma jistax ikun fiha … karattri speċjali”

I’ve been spending some time cleaning up a SharePoint 2010 site and one of the cleanup issues relates to a corrupt / incorrectly installed SQL Server Report Services issue.  The issue arose when one of my colleagues tried to save a site as a template and then create create a new site based on that template.  The save operation worked fine, but when she tried to create the new site, SharePoint displayed the following error message:

Error

The content type name ‘$Resources:ReportServerResources,DataSourceContentTypeName;’ cannot contain: \ / : * ? " # % < > { } | ~ & , two consecutive periods (..), or special characters such as a tab.

Here’s a screen cap:

 

image

I had a look at the content types in the site and found this:

image

Those content types are clearly unhealthy.

This issue seems to come up a lot on the Internets and there doesn’t seem to be a single consensus on how to solve it.  I found a handy table that mapped the bad content type names to good content type names here: http://social.technet.microsoft.com/Forums/en-ZA/sharepoint2010programming/thread/cb03e866-8184-4943-acfe-cafffa1b8b7a.  I manually updated them thusly:

image

(BrightStarr in the name is obviously optional, but it can’t hurt Tbissem )

This allowed me to create a new template and didn’t break anything on the other sites, including some PerformancePoint Server stuff that a completely different group of people were working on.  I was then able to create a new site on the template.  Success!

I am not sure this is a 100% solution, but it got me and everyone involved past this annoying error.  If I find anything new, I’ll post an update.  My nervousness stems from the fact that these names shouldn’t be wrong in the first place and by fixing the display name, I am not touching the internal name. 

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Wieħed Kawza għal "Il-kreatur ta 'din tort ma speċifikax Raġuni.”

Stajt kont qed tagħmel ħafna xogħol ma 'search SharePoint aħħar u speċifikament l-klassi KeywordQuery, proprjetajiet u l-metodi.

Jekk trid li l-riżultat stabbilit li jirritornaw riżultati fuq u lil hinn mill-suspettati tas-soltu (tara hawn), inti iżżidhiex mal-ġbir SelectedProperties, kif fil-:

myKeywordQuery.SelectProperties.Add("xyzzy");

Many thanks and a tip of the hat to Corey Roth u this enormously helpful blog post (http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/19/how-to-use-the-moss-enterprise-search-keywordquery-class.aspx)

Fil-każ tiegħi, “xyzzy” isn’t actually a managed property.  When I added it to SelectedProperties anyway, SharePoint threw one of my favorite ever runtime exceptions:

“The creator of this fault did not specify a Reason.”

I especially like the capital “R” in Reason.  This sounds to me like the .NET equivalent of “I have no mouth, and I must scream."

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Handy Referenza: Default Riżultati minn KeywordQuery Fittex

Meta inti jinvokaw il-Teżegwixxi() metodu fuq KeywordQuery, inti tista 'toħloq ResultTable ibbażata fuq ResultType.RelevantResults.  Dan snippet kodiċi juri dak li jfisser I:

ResultsTableCollection ResultTableCollection = myKeywordQuery.Execute();

ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];

It-tabella li jirriżultaw se jkollhom l-kolonni li ġejjin ta 'informazzjoni: 

WorkId
Rank
Titolu
Awtur
Daqs
Path
Deskrizzjoni
Ikteb
SiteName
CollapsingStatus
HitHighlightedSummary
HitHighlightedProperties
Contentclass
IsDocument
PictureThumbnailURL
ServerRedirectedURL

I derivat din il-lista minn SharePoint 2010 ambjent, intrapriża edizzjoni.  Nisperaw se jkun handy għal xi ħadd fil-futur.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Wieħed Raġuni għall: "Naqas li estratt-fajl kabina fis-soluzzjoni”

Filwaqt li jaħdmu fuq proġett part web studio viżwali llum, Jien għamilt minuri mill-ġdid org ta 'xi fajls li għandhom jitqiegħdu fil-folder _layouts bħala parti mill-proċess iskjerament. Speċifikament, I isem ġdid fajl. JS minn "TypeAhead.js" għal "TypeAhead(qodma).JS "  I pjan biex jitneħħew malli s-suċċessur tiegħu "TypeAhead.js" juri korretta.  Hija dehru qishom dan:

image

Dan immedjatament ikkawża problema bil studio viżwali meta I ppruvaw biex jitħaddem il-proġett:

Error occurred in deployment step ‘Add Solution’: Naqas li estratt-fajl kabina fis-soluzzjoni.

Jirriżulta li inti m'għandekx tpoġġi parentesi fil-fajl ismijiet.  I jitneħħew l-parens u li tissolva l-problema.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Madankollu Aktar jQuery–Resize Image 1 Eżempju

I wiret parti minn bejjiegħ web qodma klijent u hija għandha problema daqs immaġini.  L-immaġini għandha tkun ta '60×50 iżda għal xi raġuni fard, il-bejjiegħ oriġinali sfurzat tagħhom fiċ 42×42, hekk huma jfittxu squashed:

 

Image Tajba

Bad Image

Hawn il-markup (kemmxejn simplifikata):

<tabella klassi = "estiż-prospetti">
  <thead>
    <tr>
      <th  wisa '= '100′>3 It-Tlieta</th>
    </tr>
  </thead>

  <tbody>
    <tr klassi = "previżjoni">
      <wisa td = '100′>
        <st>
          <Li klassi = "għolja">Għolja: 72&inti;F</LI>
          <Li klassi = "baxxa">Baxxa: 44&inti;F</LI>
          <Li klassi = "kundizzjoni">Sunny
            <img src =’
http://deskwx.weatherbug.com/images/Forecast/icons/localized/60×50/en/trans/cond007.png’ wisa '= '42’ għoli = '42’ alt =” />
          </LI>
        </st>
      </td>
    </tr>

  </tbody>

</tabella>

Int ser ikollok tinnota li għalkemm il- passaġġ għall-immaġni innifsu turi d-dimensjoni xierqa (60×50) il-bejjiegħ oriġinali sfurzata fil 42×42.  Għaliex?  Crazy.

Xorta waħda, Jien ridt soluzzjoni malajr u faċli biex din il-kwistjoni u I daru lejn jQuery.  Il-trick kien li jillokalizza kollha tal-każ <img> tags.  I ma riedx li muck dwar ma 'xi tags img oħra (li minnhom hemm ħafna).  Din id-daqsxejn ta 'jQuery għamlet il-trick:

<script type="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></iskrittura>

<script type="text/javascript">
     $(dokument).lest(funzjoni () {

         $(‘li.condition > img ").kull(funzjoni (indiċi, partita)
           
{
             $(partita).css("width", "60"); 
             $(partita).css("height", "50");
            });
     }); // fuq it-tagħbija dokument
</iskrittura>

Li ftit tal-kodiċi ssib il-ġbir <LI> tags li klassi hija "kundizzjoni" u <img> tfal.  Imbagħad ttenni kollha permezz ta 'dak.  Maħduma bħal CHARM.

I probabilment setgħu simplifikata, imma jien qatt ma kien it-tip ta 'Unix Guy li solvuti π li 18 numri preċiżjoni jużaw il zat u awk u jien ma dak it-tip jekk Guy jQuery jew Tbissem.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Parsing XML ma LINQ

Hawn eżempju ta 'malajr bl-użu LINQ li parse xi  XML u jiksbu fil-ħelu, attributi ħelu hemmhekk.

Hawn il-XML Irrid parse:

<?xml version="1.0" encoding="utf-8" ?>
<DeafultConfigurationSets>
  <PageLayouts>

    <PageLayout name="xyzzy">
      <Tabs>
        <Tab TabOrder="1" TabLabel="x" SharePointContentType="a" AdditionalConstraints="ac1"/>
        <Tab TabOrder="2" TabLabel="y" SharePointContentType="b" AdditionalConstraints="ac2"/>
      </Tabs>
    </PageLayout>

    <PageLayout name="xyzzy2">
      <Tabs>
        <Tab TabOrder="100" TabLabel="x" SharePointContentType="a" AdditionalConstraints="ac1"/>
        <Tab TabOrder="101" TabLabel="y" SharePointContentType="b" AdditionalConstraints="ac2"/>
        <Tab TabOrder="103" TabLabel="z" SharePointContentType="c" AdditionalConstraints="ac3"/>
      </Tabs>
    </PageLayout>

  </PageLayouts>
</DeafultConfigurationSets>

Irrid li jibnu xi tabs fil runtime mill parsing ta 'hawn fuq.  Tabs tiegħi jiddependu fuq tqassim paġna.  Jekk l-isem tqassim paġna tiegħi huwa "xyzzy2" imbagħad I rridu nġibu tabs 100, 101 u 103 (l-tabs fil <PageLayout isem = "xyzzy2">).

Hawn il-LINQ li tagħmlu:

kien allTabs =
              minn p fis
                  XElement.Parse(theXmlToParse).
                 
Elementi("PageLayouts").
                  Elementi("PageLayout")
              fejn (p.Attribute("name").Value.Equals("xyzzy2"))
              minn m p.Elements("Tabs").Elementi("Tab")
              tagħżel m;

          Results.Text = string.Empty;

          foreach (kien ATAB fis allTabs)
          {
              Results.Text =
                  "Tab Order: " + aTab.Attribute("TabOrder").Valur + " |" +
                  "Tab Label: " + aTab.Attribute("TabLabel").Valur + " | " +
                  "SharePointContentType: " + aTab.Attribute("SharePointContentType").Valur + " | " +
                  "AdditionalConstraints: " + aTab.Attribute("AdditionalConstraints").Valur + "\r";
          }

Fil-hawn fuq, il-varjabbli "theXmlToParse" hija varjabbli string, iżda tista 'tuża t-tagħbija() metodu fuq nixxiegħa jekk inti tixtieq.

"Riżultati" hija tikketta fuq formola web u meta dan il-kodiċi tesegwixxi, jidher qisu dan:

SNAGHTML11cd2e7c

I ma jkunux ħadmu kif biex issolvi r-riżultati għadhom, so I ser jitlaq minn dak għal blog post futur.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

SharePoint 2010 KeywordQuery u Utenti Anonymous

I ppermettiet aċċess anonimu fis-sit tiegħi biex tiġi ttestjata l-web parti tfittxija stajt qed jiżviluppaw u li l-ebda sorpriża kbira, hija ma pjuttost xogħol.  Aċċess Anonymous hija pjuttost ħafna dejjem sfida għalija.

F'dan il-każ, it-tfittxija inizjali ma tkunx qed taħdem għal xi raġuni.  I should say that it was running but it was not returning any results.  I’m using the KeywordQuery for that initial display.

I did a quick search and this blog post by “sowmyancs” came up fairly quickly: "SharePoint 2010 Fittex: not showing any results for anonymous users?"  That blog entry describes the problem from an out of the box keyword search perspective but the behavior was similar to mine – it worked for authenticated users and for anonymous users, but anonymous users got no results. 

I followed the instructions and bang!  It solved my issue.  I’m not sure what side effects this will have and they may prove to be a problem, but the short term result is helpful.

Click on through the blog:

image

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

SharePoint 2010 KeywordQuery u l HiddenConstraints Proprjetà

Stajt kont qed tagħmel daqsxejn ta 'xogħol ma' l- KeywordQuery oġġett fil SharePoint 2010 u jagħmlu użu mill- HiddenConstraints proprjetà.

I ma sabx informazzjoni utli immedjatament fuq il-proprjetà li, hekk ħsibt I d malajr LOGHOME stabbiliti kif stajt ilhom jużawha.

Safejn I peux, din hija restrizzjoni miżjuda mal-mistoqsija sabiex inti tista sort ta 'park hemmhekk u ma tinkwieta dwar dan awtomatiku.  Bħala tali, huwa biss ieħor keyword (jew sett ta 'keywords) u modifikaturi li inti tista tip fil lill-UI meta inti tagħmel tfittxija keyword.  Hawn eżempju:

keywordQuery.HiddenConstraints = "scope:\"Industry\"";

Inti tista 'żżid restrizzjonijiet addizzjonali ma delimetru spazju.

keywordQuery.HiddenConstraints = "scope:\"Industry\" defense";

Dan t'hawn fuq huwa qal bl-Ingliż, "Run mistoqsija keyword infittxu" difiża "u barra minn hekk, jużaw il-"Industrija" ambitu.

Hawn mod ieħor ta 'tħares lejn dan:

image

Stajt ilhom jużawha biex jipprovdu ambitu awtomatiku kuntest dipendenti fuq parti web custom.  When the user clicks on a tab and clicks a search button, the tab dictates a particular search scope.  It’s working well so far.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Eżempju: XSLT Ħolqien HTML Href tal

Stajt kont qed tagħmel daqsxejn ta 'għalf XSL aħħar u ħsibt I d tpoġġi flimkien kampjun għal referenza futura tiegħi u li jistgħu jkunu ta' valur għalina lkoll XSLT-hom teħid ta 'għajxien fil-internets.

Ikkunsidra l-XML ġej:

<FdcSearchTabsCollection Count="2">
  <SearchTab Label="Industry" SortOrder=”00” Label=”Industries” SearchConstraints="contenttype:Industrija" TabID="831b2a74-98c4-4453-8061-86e2fdb22c63"/>
  <SearchTab Label="Practices" SortOrder=”01” Label=”Practices” SearchConstraints="contenttype:PracticeGroups" TabID="678e206b-6996-421f-9765-b0558fe1a9c0"/>
</FdcSearchTabsCollection>

Il snippet XSL ġej ser jiġġenera lista magħżula ta 'tabs hrefs:

<XSL:template match="FdcSearchTabsCollection" xml:space="preserve">
   
    <!– The "all" tab –>
    <a href="javascript:ViewTab(‘All’)">Ara kollox</a>
   
    <!– Kull tab individwali –>
    <!– Jtenni permezz kollha Tabs u juru l-korretta  rabtiet. –>
    <XSL:for-each select="SearchTab">
      <XSL:sort select="@SortOrder"/>

      …
      <a href="javascript:ViewTab("{@TabID}")"><XSL:value-of select="@Label"/></a>
    </XSL:għal-kull>

    <br /> 
   

   </XSL:template>

Hawn dak li jidher qisu fil SharePoint:

SNAGHTML78aa2cb

 

 

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin