Skip to content Skip to sidebar Skip to footer

Pjax.reload Cannot Read Property 'reload' of Undefined

وورد ورد روبن موضوع كل موقع pjax دون تحديث

مقدمة

بادئ ذي بدء ، إنها ليست احترافية. إنها طبق. ستحصل عليه pjax من المحطة بأكملها ، ولكن ستكون هناك العديد من المشاكل. يمكن للأصدقاء المهتمين رميها وإكمالها!

الدورة التعليمية

الخطوة الأولى: مرجع ملف jquery.js في ملف header.php قبل النص الأساسي ، بشكل عام ، لا تحتاج إلى الرجوع إلى القوالب. يجب وضعه أمام jquery.pjax.js

        
  1. // jquery.pjax.js
  2. // copyright chris wanstrath
  3. // https://github.com/defunkt/jquery-pjax
  4. (function($){
  5. // When chosen on a container with a selector, fetches the href with
  6. // ajax into the container or with the data-pjax aspect on the link
  7. // itself.
  8. //
  9. // Tries to make sure the back button and ctrl+click work the way
  10. // you'd expect.
  11. //
  12. // Exported as $.fn.pjax
  13. //
  14. // Accepts a jQuery ajax options object that may include these
  15. // pjax specific options:
  16. //
  17. //
  18. // container - Where to stick the response body. Usually a String selector.
  19. // $(container).html(xhr.responseBody)
  20. // (default: electric current jquery context)
  21. // push - Whether to pushState the URL. Defaults to true (of course).
  22. // replace - Want to utilize replaceState instead? That's cool.
  23. //
  24. // For convenience the second parameter can be either the container or
  25. // the options object.
  26. //
  27. // Returns the jQuery object
  28. function fnPjax(selector, container, options) {
  29. var context = this
  30. return this.on('click.pjax', selector, function(outcome) {
  31. var opts = $.extend({}, optionsFor(container, options))
  32. if (!opts.container)
  33. opts.container = $(this).attr('information-pjax') || context
  34. handleClick(event, opts)
  35. })
  36. }
  37. // Public: pjax on click handler
  38. //
  39. // Exported every bit $.pjax.click.
  40. //
  41. // event - "click" jQuery.Result
  42. // options - pjax options
  43. //
  44. // Examples
  45. //
  46. // $(document).on('click', 'a', $.pjax.click)
  47. // // is the same as
  48. // $(certificate).pjax('a')
  49. //
  50. // $(document).on('click', 'a', function(issue) {
  51. // var container = $(this).closest('[data-pjax-container]')
  52. // $.pjax.click(event, container)
  53. // })
  54. //
  55. // Returns nothing.
  56. function handleClick(event, container, options) {
  57. options = optionsFor(container, options)
  58. var link = outcome.currentTarget
  59. if (link.tagName.toUpperCase() !== 'A')
  60. throw "$.fn.pjax or $.pjax.click requires an ballast element"
  61. // Middle click, cmd click, and ctrl click should open
  62. // links in a new tab as normal.
  63. if ( upshot.which > one || upshot.metaKey || event.ctrlKey || event.shiftKey || event.altKey )
  64. return
  65. // Ignore cantankerous origin links
  66. if ( location.protocol !== link.protocol || location.hostname !== link.hostname )
  67. return
  68. // Ignore anchors on the same page
  69. if (link.hash && link.href.replace(link.hash, '') ===
  70. location.href.replace(location.hash, ''))
  71. return
  72. // Ignore empty anchor "foo.html#"
  73. if (link.href === location.href + '#')
  74. return
  75. // Ignore event with default prevented
  76. if (consequence.isDefaultPrevented())
  77. return
  78. var defaults = {
  79. url: link.href,
  80. container: $(link).attr('data-pjax'),
  81. target: link
  82. }
  83. var opts = $.extend({}, defaults, options)
  84. var clickEvent = $.Event('pjax:click')
  85. $(link).trigger(clickEvent, [opts])
  86. if (!clickEvent.isDefaultPrevented()) {
  87. pjax(opts)
  88. event.preventDefault()
  89. $(link).trigger('pjax:clicked', [opts])
  90. }
  91. }
  92. // Public: pjax on form submit handler
  93. //
  94. // Exported every bit $.pjax.submit
  95. //
  96. // event - "click" jQuery.Event
  97. // options - pjax options
  98. //
  99. // Examples
  100. //
  101. // $(document).on('submit', 'form', function(issue) {
  102. // var container = $(this).closest('[information-pjax-container]')
  103. // $.pjax.submit(effect, container)
  104. // })
  105. //
  106. // Returns nothing.
  107. role handleSubmit(event, container, options) {
  108. options = optionsFor(container, options)
  109. var form = event.currentTarget
  110. if (form.tagName.toUpperCase() !== 'FORM')
  111. throw "$.pjax.submit requires a form chemical element"
  112. var defaults = {
  113. type: form.method.toUpperCase(),
  114. url: form.action,
  115. information: $(form).serializeArray(),
  116. container: $(form).attr('data-pjax'),
  117. target: form
  118. }
  119. pjax($.extend({}, defaults, options))
  120. event.preventDefault()
  121. }
  122. // Loads a URL with ajax, puts the response body inside a container,
  123. // and so pushState()'southward the loaded URL.
  124. //
  125. // Works just like $.ajax in that information technology accepts a jQuery ajax
  126. // settings object (with keys like url, type, data, etc).
  127. //
  128. // Accepts these extra keys:
  129. //
  130. // container - Where to stick the response body.
  131. // $(container).html(xhr.responseBody)
  132. // push button - Whether to pushState the URL. Defaults to truthful (of course).
  133. // replace - Desire to use replaceState instead? That'southward cool.
  134. //
  135. // Use it but similar $.ajax:
  136. //
  137. // var xhr = $.pjax({ url: this.href, container: '#primary' })
  138. // console.log( xhr.readyState )
  139. //
  140. // Returns whatsoever $.ajax returns.
  141. function pjax(options) {
  142. options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options)
  143. if ($.isFunction(options.url)) {
  144. options.url = options.url()
  145. }
  146. var target = options.target
  147. var hash = parseURL(options.url).hash
  148. var context = options.context = findContainerFor(options.container)
  149. // We desire the browser to maintain two separate internal caches: one
  150. // for pjax'd partial page loads and one for normal page loads.
  151. // Without calculation this secret parameter, some browsers will oftentimes
  152. // misfile the two.
  153. if (!options.information) options.data = {}
  154. options.information._pjax = context.selector
  155. office fire(blazon, args) {
  156. var event = $.Result(type, { relatedTarget: target })
  157. context.trigger(event, args)
  158. render !effect.isDefaultPrevented()
  159. }
  160. var timeoutTimer
  161. options.beforeSend = role(xhr, settings) {
  162. // No timeout for not-GET requests
  163. // Its not safe to request the resources again with a fallback method.
  164. if (settings.type !== 'GET') {
  165. settings.timeout = 0
  166. }
  167. xhr.setRequestHeader('10-PJAX', 'truthful')
  168. xhr.setRequestHeader('X-PJAX-Container', context.selector)
  169. if (!fire('pjax:beforeSend', [xhr, settings]))
  170. return fake
  171. if (settings.timeout > 0) {
  172. timeoutTimer = setTimeout(part() {
  173. if (fire('pjax:timeout', [xhr, options]))
  174. xhr.abort('timeout')
  175. }, settings.timeout)
  176. // Articulate timeout setting so jquerys internal timeout isn't invoked
  177. settings.timeout = 0
  178. }
  179. options.requestUrl = parseURL(settings.url).href
  180. }
  181. options.complete = function(xhr, textStatus) {
  182. if (timeoutTimer)
  183. clearTimeout(timeoutTimer)
  184. fire('pjax:complete', [xhr, textStatus, options])
  185. burn down('pjax:end', [xhr, options])
  186. }
  187. options.error = function(xhr, textStatus, errorThrown) {
  188. var container = extractContainer("", xhr, options)
  189. var allowed = burn down('pjax:error', [xhr, textStatus, errorThrown, options])
  190. if (options.type == 'Go' && textStatus !== 'arrest' && allowed) {
  191. locationReplace(container.url)
  192. }
  193. }
  194. options.success = office(data, status, xhr) {
  195. // If $.pjax.defaults.version is a function, invoke it first.
  196. // Otherwise it tin exist a static string.
  197. var currentVersion = (typeof $.pjax.defaults.version === 'part') ?
  198. $.pjax.defaults.version() :
  199. $.pjax.defaults.version
  200. var latestVersion = xhr.getResponseHeader('X-PJAX-Version')
  201. var container = extractContainer(data, xhr, options)
  202. // If there is a layout version mismatch, hard load the new url
  203. if (currentVersion && latestVersion && currentVersion !== latestVersion) {
  204. locationReplace(container.url)
  205. return
  206. }
  207. // If the new response is missing a body, hard load the page
  208. if (!container.contents) {
  209. locationReplace(container.url)
  210. return
  211. }
  212. pjax.state = {
  213. id: options.id || uniqueId(),
  214. url: container.url,
  215. title: container.title,
  216. container: context.selector,
  217. fragment: options.fragment,
  218. timeout: options.timeout
  219. }
  220. if (options.push || options.replace) {
  221. window.history.replaceState(pjax.state, container.title, container.url)
  222. }
  223. // Clear out whatsoever focused controls before inserting new folio contents.
  224. try {
  225. document.activeElement.blur()
  226. } catch (east) { }
  227. if (container.title) document.title = container.championship
  228. fire('pjax:beforeReplace', [container.contents, options])
  229. context.html(container.contents)
  230. // FF issues: Won't autofocus fields that are inserted via JS.
  231. // This behavior is incorrect. Then if theres no current focus, autofocus
  232. // the last field.
  233. //
  234. // http://world wide web.w3.org/html/wg/drafts/html/master/forms.html
  235. var autofocusEl = context.find('input[autofocus], textarea[autofocus]').last()[0]
  236. if (autofocusEl && document.activeElement !== autofocusEl) {
  237. autofocusEl.focus();
  238. }
  239. executeScriptTags(container.scripts)
  240. // Scroll to meridian past default
  241. if (typeof options.scrollTo === 'number')
  242. $(window).scrollTop(options.scrollTo)
  243. // If the URL has a hash in it, make sure the browser
  244. // knows to navigate to the hash.
  245. if ( hash !== '' ) {
  246. // Avoid using simple hash set here. Will add together another history
  247. // entry. Supercede the url with replaceState and roll to target
  248. // by mitt.
  249. //
  250. // window.location.hash = hash
  251. var url = parseURL(container.url)
  252. url.hash = hash
  253. pjax.land.url = url.href
  254. window.history.replaceState(pjax.state, container.title, url.href)
  255. var target = $(url.hash)
  256. if (target.length) $(window).scrollTop(target.outset().pinnacle)
  257. }
  258. burn down('pjax:success', [information, status, xhr, options])
  259. }
  260. // Initialize pjax.state for the initial folio load. Presume we're
  261. // using the container and options of the link we're loading for the
  262. // dorsum push to the initial page. This ensures good back push
  263. // behavior.
  264. if (!pjax.state) {
  265. pjax.land = {
  266. id: uniqueId(),
  267. url: window.location.href,
  268. title: document.title,
  269. container: context.selector,
  270. fragment: options.fragment,
  271. timeout: options.timeout
  272. }
  273. window.history.replaceState(pjax.country, certificate.championship)
  274. }
  275. // Abolish the current request if we're already pjaxing
  276. var xhr = pjax.xhr
  277. if ( xhr && xhr.readyState < 4) {
  278. xhr.onreadystatechange = $.noop
  279. xhr.abort()
  280. }
  281. pjax.options = options
  282. var xhr = pjax.xhr = $.ajax(options)
  283. if (xhr.readyState > 0) {
  284. if (options.button && !options.supersede) {
  285. // Cache current container element before replacing information technology
  286. cachePush(pjax.land.id, context.clone().contents())
  287. window.history.pushState(naught, "", stripPjaxParam(options.requestUrl))
  288. }
  289. burn('pjax:start', [xhr, options])
  290. fire('pjax:ship', [xhr, options])
  291. }
  292. return pjax.xhr
  293. }
  294. // Public: Reload current folio with pjax.
  295. //
  296. // Returns whatsoever $.pjax returns.
  297. part pjaxReload(container, options) {
  298. var defaults = {
  299. url: window.location.href,
  300. push: false,
  301. replace: true,
  302. scrollTo: false
  303. }
  304. return pjax($.extend(defaults, optionsFor(container, options)))
  305. }
  306. // Internal: Hard replace current state with url.
  307. //
  308. // Piece of work for effectually WebKit
  309. // https://bugs.webkit.org/show_bug.cgi?id=93506
  310. //
  311. // Returns nothing.
  312. function locationReplace(url) {
  313. window.history.replaceState(nil, "", "#")
  314. window.location.replace(url)
  315. }
  316. var initialPop = true
  317. var initialURL = window.location.href
  318. var initialState = window.history.state
  319. // Initialize $.pjax.state if possible
  320. // Happens when reloading a page and coming forward from a different
  321. // session history.
  322. if (initialState && initialState.container) {
  323. pjax.state = initialState
  324. }
  325. // Non-webkit browsers don't fire an initial popstate event
  326. if ('state' in window.history) {
  327. initialPop = false
  328. }
  329. // popstate handler takes intendance of the back and frontwards buttons
  330. //
  331. // Y'all probably shouldn't employ pjax on pages with other pushState
  332. // stuff even so.
  333. function onPjaxPopstate(event) {
  334. var state = event.state
  335. if (state && land.container) {
  336. // When coming forward from a dissever history session, volition get an
  337. // initial pop with a state we are already at. Skip reloading the current
  338. // page.
  339. if (initialPop && initialURL == land.url) render
  340. // If popping back to the aforementioned country, just skip.
  341. // Could exist clicking back from hashchange rather than a pushState.
  342. if (pjax.state && pjax.land.id === state.id) render
  343. var container = $(country.container)
  344. if (container.length) {
  345. var direction, contents = cacheMapping[state.id]
  346. if (pjax.state) {
  347. // Since country ids ever increase, nosotros tin deduce the history
  348. // management from the previous state.
  349. direction = pjax.state.id < state.id ? 'forward' : 'back'
  350. // Enshroud electric current container before replacement and inform the
  351. // cache which management the history shifted.
  352. cachePop(direction, pjax.state.id, container.clone().contents())
  353. }
  354. var popstateEvent = $.Result('pjax:popstate', {
  355. state: land,
  356. management: direction
  357. })
  358. container.trigger(popstateEvent)
  359. var options = {
  360. id: land.id,
  361. url: state.url,
  362. container: container,
  363. push: false,
  364. fragment: land.fragment,
  365. timeout: state.timeout,
  366. scrollTo: simulated
  367. }
  368. if (contents) {
  369. container.trigger('pjax:start', [cipher, options])
  370. if (state.championship) document.title = land.championship
  371. container.trigger('pjax:beforeReplace', [contents, options])
  372. container.html(contents)
  373. pjax.country = state
  374. container.trigger('pjax:end', [null, options])
  375. } else {
  376. pjax(options)
  377. }
  378. // Strength reflow/relayout before the browser tries to restore the
  379. // scroll position.
  380. container[0].offsetHeight
  381. } else {
  382. locationReplace(location.href)
  383. }
  384. }
  385. initialPop = false
  386. }
  387. // Fallback version of main pjax role for browsers that don't
  388. // support pushState.
  389. //
  390. // Returns goose egg since information technology retriggers a hard class submission.
  391. part fallbackPjax(options) {
  392. var url = $.isFunction(options.url) ? options.url() : options.url,
  393. method = options.type ? options.type.toUpperCase() : 'GET'
  394. var form = $('<form>', {
  395. method: method === 'GET' ? 'Go' : 'POST',
  396. action: url,
  397. style: 'brandish:none'
  398. })
  399. if (method !== 'GET' && method !== 'Post') {
  400. form.suspend($('<input>', {
  401. type: 'hidden',
  402. proper name: '_method',
  403. value: method.toLowerCase()
  404. }))
  405. }
  406. var information = options.data
  407. if (typeof data === 'string') {
  408. $.each(data.split up('&'), function(index, value) {
  409. var pair = value.split('=')
  410. form.append($('<input>', {type: 'hidden', proper name: pair[0], value: pair[1]}))
  411. })
  412. } else if (typeof data === 'object') {
  413. for (cardinal in data)
  414. form.append($('<input>', {blazon: 'hidden', name: key, value: data[key]}))
  415. }
  416. $(certificate.trunk).append(course)
  417. class.submit()
  418. }
  419. // Internal: Generate unique id for country object.
  420. //
  421. // Use a timestamp instead of a counter since ids should even so be
  422. // unique across page loads.
  423. //
  424. // Returns Number.
  425. function uniqueId() {
  426. return (new Date).getTime()
  427. }
  428. // Internal: Strips _pjax param from url
  429. //
  430. // url - String
  431. //
  432. // Returns Cord.
  433. function stripPjaxParam(url) {
  434. return url
  435. .replace(/\?_pjax=[^&]+&?/, '?')
  436. .replace(/_pjax=[^&]+&?/, '')
  437. .replace(/[\?&]$/, '')
  438. }
  439. // Internal: Parse URL components and returns a Locationish object.
  440. //
  441. // url - Cord URL
  442. //
  443. // Returns HTMLAnchorElement that acts similar Location.
  444. function parseURL(url) {
  445. var a = document.createElement('a')
  446. a.href = url
  447. return a
  448. }
  449. // Internal: Build options Object for arguments.
  450. //
  451. // For convenience the first parameter tin can be either the container or
  452. // the options object.
  453. //
  454. // Examples
  455. //
  456. // optionsFor('#container')
  457. // // => {container: '#container'}
  458. //
  459. // optionsFor('#container', {push button: true})
  460. // // => {container: '#container', push: true}
  461. //
  462. // optionsFor({container: '#container', push: true})
  463. // // => {container: '#container', button: truthful}
  464. //
  465. // Returns options Object.
  466. function optionsFor(container, options) {
  467. // Both container and options
  468. if ( container && options )
  469. options.container = container
  470. // First argument is options Object
  471. else if ( $.isPlainObject(container) )
  472. options = container
  473. // Merely container
  474. else
  475. options = {container: container}
  476. // Find and validate container
  477. if (options.container)
  478. options.container = findContainerFor(options.container)
  479. return options
  480. }
  481. // Internal: Discover container element for a variety of inputs.
  482. //
  483. // Because we can't persist elements using the history API, we must exist
  484. // able to find a String selector that will consistently notice the Chemical element.
  485. //
  486. // container - A selector Cord, jQuery object, or DOM Element.
  487. //
  488. // Returns a jQuery object whose context is `certificate` and has a selector.
  489. office findContainerFor(container) {
  490. container = $(container)
  491. if ( !container.length ) {
  492. throw "no pjax container for " + container.selector
  493. } else if ( container.selector !== '' && container.context === certificate ) {
  494. return container
  495. } else if ( container.attr('id') ) {
  496. return $('#' + container.attr('id'))
  497. } else {
  498. throw "cant become selector for pjax container!"
  499. }
  500. }
  501. // Internal: Filter and find all elements matching the selector.
  502. //
  503. // Where $.fn.find only matches descendants, findAll volition test all the
  504. // top level elements in the jQuery object likewise.
  505. //
  506. // elems - jQuery object of Elements
  507. // selector - String selector to match
  508. //
  509. // Returns a jQuery object.
  510. part findAll(elems, selector) {
  511. render elems.filter(selector).add(elems.find(selector));
  512. }
  513. role parseHTML(html) {
  514. return $.parseHTML(html, document, true)
  515. }
  516. // Internal: Extracts container and metadata from response.
  517. //
  518. // i. Extracts X-PJAX-URL header if fix
  519. // 2. Extracts inline <title> tags
  520. // 3. Builds response Chemical element and extracts fragment if set
  521. //
  522. // data - Cord response data
  523. // xhr - XHR response
  524. // options - pjax options Object
  525. //
  526. // Returns an Object with url, championship, and contents keys.
  527. function extractContainer(information, xhr, options) {
  528. var obj = {}
  529. // Prefer X-PJAX-URL header if it was prepare, otherwise fallback to
  530. // using the original requested url.
  531. obj.url = stripPjaxParam(xhr.getResponseHeader('X-PJAX-URL') || options.requestUrl)
  532. // Attempt to parse response html into elements
  533. if (/<html/i.test(data)) {
  534. var $head = $(parseHTML(data.match(/<head[^>]*>([\south\S.]*)<\/caput>/i)[0]))
  535. var $body = $(parseHTML(data.lucifer(/<body[^>]*>([\due south\S.]*)<\/trunk>/i)[0]))
  536. } else {
  537. var $caput = $torso = $(parseHTML(information))
  538. }
  539. // If response information is empty, return fast
  540. if ($body.length === 0)
  541. render obj
  542. // If there's a <title> tag in the header, apply it equally
  543. // the folio's championship.
  544. obj.championship = findAll($head, 'championship').last().text()
  545. if (options.fragment) {
  546. // If they specified a fragment, look for it in the response
  547. // and pull it out.
  548. if (options.fragment === 'body') {
  549. var $fragment = $body
  550. } else {
  551. var $fragment = findAll($body, options.fragment).first()
  552. }
  553. if ($fragment.length) {
  554. obj.contents = $fragment.contents()
  555. // If in that location's no title, wait for information-title and title attributes
  556. // on the fragment
  557. if (!obj.title)
  558. obj.title = $fragment.attr('title') || $fragment.data('championship')
  559. }
  560. } else if (!/<html/i.exam(data)) {
  561. obj.contents = $trunk
  562. }
  563. // Clean up any <championship> tags
  564. if (obj.contents) {
  565. // Remove whatsoever parent title elements
  566. obj.contents = obj.contents.not(function() { return $(this).is('championship') })
  567. // So scrub whatever titles from their descendants
  568. obj.contents.detect('title').remove()
  569. // Get together all script[src] elements
  570. obj.scripts = findAll(obj.contents, 'script[src]').remove()
  571. obj.contents = obj.contents.not(obj.scripts)
  572. }
  573. // Trim any whitespace off the title
  574. if (obj.championship) obj.title = $.trim(obj.title)
  575. render obj
  576. }
  577. // Load an execute scripts using standard script request.
  578. //
  579. // Avoids jQuery's traditional $.getScript which does a XHR request and
  580. // globalEval.
  581. //
  582. // scripts - jQuery object of script Elements
  583. //
  584. // Returns naught.
  585. role executeScriptTags(scripts) {
  586. if (!scripts) return
  587. var existingScripts = $('script[src]')
  588. scripts.each(function() {
  589. var src = this.src
  590. var matchedScripts = existingScripts.filter(part() {
  591. return this.src === src
  592. })
  593. if (matchedScripts.length) return
  594. var script = certificate.createElement('script')
  595. script.type = $(this).attr('type')
  596. script.src = $(this).attr('src')
  597. document.head.appendChild(script)
  598. })
  599. }
  600. // Internal: History DOM caching form.
  601. var cacheMapping = {}
  602. var cacheForwardStack = []
  603. var cacheBackStack = []
  604. // Push previous state id and container contents into the history
  605. // enshroud. Should exist called in conjunction with `pushState` to save the
  606. // previous container contents.
  607. //
  608. // id - Country ID Number
  609. // value - DOM Element to cache
  610. //
  611. // Returns zilch.
  612. function cachePush(id, value) {
  613. cacheMapping[id] = value
  614. cacheBackStack.push(id)
  615. // Remove all entires in forward history stack after pushing
  616. // a new page.
  617. while (cacheForwardStack.length)
  618. delete cacheMapping[cacheForwardStack.shift()]
  619. // Trim back history stack to max cache length.
  620. while (cacheBackStack.length > pjax.defaults.maxCacheLength)
  621. delete cacheMapping[cacheBackStack.shift()]
  622. }
  623. // Shifts cache from directional history cache. Should be
  624. // called on `popstate` with the previous land id and container
  625. // contents.
  626. //
  627. // management - "forrard" or "back" String
  628. // id - Country ID Number
  629. // value - DOM Chemical element to enshroud
  630. //
  631. // Returns zero.
  632. function cachePop(management, id, value) {
  633. var pushStack, popStack
  634. cacheMapping[id] = value
  635. if (management === 'frontward') {
  636. pushStack = cacheBackStack
  637. popStack = cacheForwardStack
  638. } else {
  639. pushStack = cacheForwardStack
  640. popStack = cacheBackStack
  641. }
  642. pushStack.push(id)
  643. if (id = popStack.pop())
  644. delete cacheMapping[id]
  645. }
  646. // Public: Find version identifier for the initial page load.
  647. //
  648. // Returns Cord version or undefined.
  649. function findVersion() {
  650. return $('meta').filter(function() {
  651. var proper noun = $(this).attr('http-equiv')
  652. return name && name.toUpperCase() === 'X-PJAX-VERSION'
  653. }).attr('content')
  654. }
  655. // Install pjax functions on $.pjax to enable pushState behavior.
  656. //
  657. // Does nothing if already enabled.
  658. //
  659. // Examples
  660. //
  661. // $.pjax.enable()
  662. //
  663. // Returns nothing.
  664. function enable() {
  665. $.fn.pjax = fnPjax
  666. $.pjax = pjax
  667. $.pjax.enable = $.noop
  668. $.pjax.disable = disable
  669. $.pjax.click = handleClick
  670. $.pjax.submit = handleSubmit
  671. $.pjax.reload = pjaxReload
  672. $.pjax.defaults = {
  673. timeout: 650,
  674. button: truthful,
  675. replace: false,
  676. type: 'Get',
  677. dataType: 'html',
  678. scrollTo: 0,
  679. maxCacheLength: 20,
  680. version: findVersion
  681. }
  682. $(window).on('popstate.pjax', onPjaxPopstate)
  683. }
  684. // Disable pushState beliefs.
  685. //
  686. // This is the example when a browser doesn't support pushState. Information technology is
  687. // sometimes useful to disable pushState for debugging on a modern
  688. // browser.
  689. //
  690. // Examples
  691. //
  692. // $.pjax.disable()
  693. //
  694. // Returns nothing.
  695. role disable() {
  696. $.fn.pjax = office() { return this }
  697. $.pjax = fallbackPjax
  698. $.pjax.enable = enable
  699. $.pjax.disable = $.noop
  700. $.pjax.click = $.noop
  701. $.pjax.submit = $.noop
  702. $.pjax.reload = function() { window.location.reload() }
  703. $(window).off('popstate.pjax', onPjaxPopstate)
  704. }
  705. // Add the land property to jQuery'due south event object so we can use it in
  706. // $(window).bind('popstate')
  707. if ( $.inArray('state', $.event.props) < 0 )
  708. $.issue.props.push button('land')
  709. // Is pjax supported by this browser?
  710. $.support.pjax =
  711. window.history && window.history.pushState && window.history.replaceState &&
  712. // pushState isn't reliable on iOS until 5.
  713. !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/)
  714. $.support.pjax ? enable() : disable()
  715. })(jQuery);

الخطوة 2: ضع الكود التالي أمام النص في ملف header.php. لاحظ أنه يرجى استبدال [] بـ <> في الكود أدناه

        
  1. [script type="text/javascript"]
  2. $(certificate).pjax('a', '#page', {fragment:'#page', timeout:8000});
  3. [/script]

ثم قم بتحديث موقع الويب الخاص بك لتجربة الشعور بعدم التحديث على الموقع بأكمله ، والقوالب الأخرى ، وما إلى ذلك

طبع يرجى ترك حقوق الطبع والنشر بلوق المارة

العنوان الأصلي

التفكير الأخير في استراتيجية CI / CD ونموذج فرع git

في الشهرين الماضيين ، بسبب مرحلة التكيف الشخصي للبيئة الجديدة والمشاريع الجديدة ، لم أقم بتربية الكثير من قلمي لكتابة المقالات. هناك العديد من الأفكار في المنتصف التي أريد تسجيلها ومشاركتها ، لكنني مق...

ممارسة مشروع جافا: آلة حاسبة (مع شفرة المصدر)

حاسبة الموضوع محتوى التصميمتصميم تطبيق حاسبة واجهة رسومية (GUI) لإكمال العمليات الحسابية البسيطة ، متطلبات التصميم يمكن لبرنامج تطبيق الآلة الحاسبة المصمم إكمال العمليات الرئيسية والطرح والضرب والقسمة...

golang ثابت

ثابت ثابت هو معرف لقيمة بسيطة، ولن يتم تعديله عند تشغيل البرنامج. يمكن أن يكون نوع البيانات في الثابت فقط منطقية، الرقمية (عدد صحيح، نقطة عائمة، الجمع) ونوع السلسلة. المستخدمة في golang.constتعال إلى ...

مشغل comsol مع setval والعطل

في الآونة الأخيرة، قابلت العديد من المشغلين عندما تعلمت النموذج وسجلوا يوميات التعلم هنا. التعبير الأصلي هو: withsol ('cpsol1'، solid.cp1.sigmatmp6، setval (loadingcase، 6)) استخدام withol. العثور على...

لينكس ملف الضغط

لينكس نظام الضغط المحتوى أدوات محلول: Compreee، غزيب BZIP2، في XZ، Zip أداة الأرشيف: القطران، CPIO أداة الضغط مضغوط ضغط / إلغاء ضغط: وهو يقابل الملفات (أدوات الضغط المبكر) مع تنسيقات التي لا نهاية لها...

قائمة الارتباط 05 حذف

حذف العقدة أو العثور على عقدة السلف المراد حذفها؛ في الوقت نفسه، اخراج العقدة المراد حذفها، حيث أن عقدة محرك الأقراص الأمامي "تقفز" جسرها الخاص؛ الانتباه إلى حالة أثناء الدوراتprev.next != n...

الاختلافات بين Tomcat و Nginx، Apache

خادم HTTP هو أساسا مثل هذه الأشياء القليلة: مراقبة ميناء قبول (قبول) اتصال مأخذ قرار طلب HTTP توزيع الطلبات باستخدام بروتوكولات عامة أو خاصة تشغيل النتائج الناتجة عن طريق تلقي طلبات التوزيع قم بتنسيق ...

pittsandents.blogspot.com

Source: https://arabicprogrammer.com/article/6996451998/

Post a Comment for "Pjax.reload Cannot Read Property 'reload' of Undefined"